Coming Up for Air

Java 7, NetBeans, Mac OS X, and a Little Bit of JavaFX 2

Monday, April 09, 2012 |

In a recent post showing how to use JavaFX 2 and NetBeans on the Mac, I noted that I have been unable to run NetBeans using Java 7 on my Mac for reasons I had not been able to figure out. Now, thanks to a pointer from Scott Kovatch, the technical lead at Oracle for the Mac OS X port of Java, I think I can show you how to do that.

In case you missed it, here is his suggestion:

The problem you’re seeing with Java 7 and text on the Mac is a known problem. If you are on a MacBook Pro a workaround is to turn off ‘Automatic graphics switching’ in the Energy Saver preference pane. We think we have a fix.

It’s a simple enough fix that you probably won’t need screen shots, but I’ll do it anyway. :) First, open up your System Preferences and select "Energy Saver":

systemprefs 300x251

Now uncheck "Automatic Grahpics Switching":

graphicsswitching 300x251

In case you haven’t installed Java 7, you can grab it here. Once that’s downloaded, open the image and run the installer. This will install the JVM into /Library/Java/JavaVirtualMachines/1.7.0.jdk. Once that’s ready, you need to modify NetBeans to use the new JDK. The only way I’ve found to do this is to edit netbeans.conf:

1
sudo vi /Applications/NetBeans\ 7.1.1.app/Contents/Resources/NetBeans/etc/netbeans.conf

Your path may be slightly different, as I moved NetBeans out of the NetBeans folder the installer created, so you may have something like /Applications/NetBeans/NetBeans\ 7.1.1.app/Contents/Resources/NetBeans/etc/netbeans.conf. At about line 19 or so, you should something like this:

1
#netbeans_jdkhome="/path/to/jdk"

which I changed to this:

1
netbeans_jdkhome=/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home

Save that, then (re)start NetBeans. You can verify that you are running the correct JDK by opening the About window:

aboutnetbeans 256x300

From here, if you want to set things up for JavaFX work, just follow the steps in my last post, but point the Platform Home as well as the JavaFX SDK folder at your Java 7 installation folder, as the Mac OS X JDK previews now ship with JavaFX bundled.

With that, you should be set. If you have any questions, leave a comment, and I’ll make some more swags to see if I can find you an answer. :)

Search

    Quotes

    Sample quote

    Quote source

    About

    My name is Jason Lee. I am a software developer living in the middle of Oklahoma. I’ve been a professional developer since 1997, using a variety of languages, including Java, Javascript, PHP, Python, Delphi, and even a bit of C#. I currently work for Red Hat on the WildFly/EAP team, where, among other things, I maintain integrations for some MicroProfile specs, OpenTelemetry, Micrometer, Jakarta Faces, and Bean Validation. (Full resume here. LinkedIn profile)

    I am the president of the Oklahoma City JUG, and an occasional speaker at the JUG and a variety of technical conferences.

    On the personal side, I’m active in my church, and enjoy bass guitar, running, fishing, and a variety of martial arts. I’m also married to a beautiful woman, and have two boys, who, thankfully, look like their mother.

    My Links

    Publications