What Is New in Java 6
| Category | Key Updates |
|---|---|
| New Features | Scripting Language Support, Web Services Enhancements, JDBC 4.0, Java Compiler API |
| Core Improvements | Pluggable Annotation Processing, JConsole Monitoring & Management, Improved Desktop Integration |
| Performance | Garbage Collection Ergonomics, Improved Lock Contention Handling |
| Deprecated & Removed | Older JDBC APIs, JAXM, CORBA Stub Compiler (rmic -iiop) |
What scripting support was added?
Java SE 6 integrated scripting languages directly into the platform through JSR 223. This lets you call engines like JavaScript (Mozilla Rhino), Ruby, or Groovy from your Java code. You use the ScriptEngineManager to get a ScriptEngine instance and execute scripts.
In practice, this was huge for embedding configuration logic or rules engines without building a custom interpreter. You could pass Java objects into the script context and get results back, making the JVM a true polyglot environment.
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("JavaScript");
Object result = engine.eval("function greet() { return 'Hello, World!'; }; greet();");
How did web services get better?
The platform gained first-class support for publishing and consuming web services. You could annotate a plain Java class with @WebService and use the new Endpoint.publish() method to expose it as a SOAP service instantly.
On the client side, the new javax.xml.ws.Service API provided a much cleaner way to consume services compared to the older, more cumbersome approaches. This matters because it finally made web services feel like a native part of Java SE, not just an EE add-on.
What changed in JDBC 4.0?
JDBC 4.0 was a major quality-of-life update for database work. The biggest win was automatic driver loading - you no longer needed to call Class.forName() to register the driver. Just drop the JAR and the DriverManager finds it.
It also added support for SQLXML data type and better exception handling with chained exceptions. For developers, this meant less boilerplate code and more robust database applications.
How was monitoring improved?
JConsole became a fully supported, out-of-the-box monitoring tool. It could attach to any local or remote Java 6 JVM to visualize memory usage, thread states, and JMX bean attributes in real-time.
This was a game-changer for troubleshooting production issues. Instead of guessing why an app was slow, you could fire up JConsole and see exactly which locks were causing thread contention or how heap memory was behaving.
What is pluggable annotation processing?
This feature, defined by JSR 269, allowed compiler-independent processing of annotations. You could write annotation processors that ran during the compilation phase to generate code, validate constraints, or create metadata files.
In practice, this is what enabled modern libraries like Lombok and MapStruct to work their magic. It opened the door for powerful metaprogramming techniques directly within the standard javac compiler.
FAQ
Do I still need to call Class.forName() to load a JDBC driver in Java 6?
No. JDBC 4.0 introduced automatic driver discovery via the service provider mechanism. As long as your driver JAR contains the proper META-INF/services/java.sql.Driver file, the DriverManager will load it automatically.
Can I use JavaScript directly in my Java 6 application?
Yes. The built-in Mozilla Rhino engine allows you to execute JavaScript code. You can pass Java objects to scripts and call script functions from Java, enabling powerful scripting capabilities.
What replaced the old rmic -iiop compiler?
The CORBA stub compiler (rmic -iiop) was deprecated. For IIOP interoperability, you should use the available alternatives that don't require pre-compiling stubs, as the technology was being phased out.
Is JConsole included with the JDK or do I need to install it separately?
JConsole is included standard with the Java 6 JDK installation. You can find it in the bin directory alongside java and javac, ready to use for monitoring any JVM.
How do I create a simple web service without an application server?
Use the @WebService annotation on your class and publish it with Endpoint.publish("http://localhost:8080/service", new MyService()). Java SE 6 includes a lightweight HTTP server for this purpose.