Installing and Configuring NetBeans IDE 7.1.2 and the Java JDK 1.7 on OS X
Recently Oracle released the JDK 1.7 for OS X (download here). This is a JDK release as of the time of this article and a consumer version of the JRE 1.7 will be released later in 2012. Today I’m going to walk through how you can install and configure the new JDK 1.7 on OS X as well as how to take advantage of it in NetBeans IDE 7.1.2.
If you have NetBeans IDE 7.1 already installed then make sure to run the update and get it running on version 7.1.2 or above.
Note: Oracle’s install docs are located here: http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html
You need to be running OS X Lion 10.7.2 or newer to install the new JDK 1.7.
Download the JDK 1.7 for OS X here. Once that is downloaded you double click the dmg file to begin walking through the guided installation process.
Once the installer finishes you will find the new JDK 1.7 located in the following folder: /Library/Java/JavaVirtualMachines/
Inside of that location you’ll see a file called 1.7.0.jdk. Double-click that file so you can set your preference to the JDK 1.7 on your system. Simply drag the JDK 1.7 to the top.
Once that is done go into the Terminal and run the following command:
|$ java -version|
You should now see the version coming back as Java 1.7 etc.
For NetBeans IDE 7.1.2 you need to go into the following menu item: Tools -> Java Platforms
A dialog will open allowing you to add another JDK version. Press the Add Platform button and another dialog will open. The new JDK should already be present in the next dialog so you just need to navigate down to: 1.7.0.jdk/contents/home and then press Next.
Step through the wizard and exit out of the dialog. JDK 1.7 should now be available to your Java projects.
To switch a NetBeans IDE project to the new JDK 1.7 make sure to right-click on the project in the Projects window. In the project properties dialog you can drill into the Build -> Compile option and then select the Java platform you want. Also note the Compile on Save option, set that as you need to.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)