Believe it or not, the Java framework installed in Lion is still stuck in the past at version 6. JDK 7 has already been released by Oracle a few months back, but Apple has now transferred the responsibility of maintaining the Mac OS X port back to Oracle.
The OpenJDK project is now in the process of porting and implementing OS X specific code from Apple into the Java mainline codebase. The current status of the port can be seen in the Mac OS X Port Project Status page. Current outstanding or incomplete features are specific to the Mac platform, like printing and locale support. If you don’t need such tight integration with the OS, you can actually start using JDK 7 for development.
For my IS200 course on Java programming (IS Software Foundations), there is a specific JDK 7 requirement for some pre-built class files distributed in the course materials. The Java 6 compiler within Lion refuses to compile and link such classes, claiming major version number incompatibility. This leaves me with no choice but to get JDK 7 up and running, or boot into Windows via Parallels (YUCK!).
In short, it is a 4 step process to get JDK 7 running with the command line.
- Download an unofficial build.
- Open /Applications/Utilities/Java Preferences.app.
- Drag both “OpenJDK 7” entries to the top of the list.
- Test java by running “java -version” in /Applications/Utilities/Terminal.app.
There is a new unofficial build every few days with new bug fixes, so bookmark the google code download page and update frequently.
With this port, it is almost 100% possible to finish the IS200 course with just Mac OS X. With the exception that the exams are conducted on Windows machines with the awful cmd.exe and NotePad++.