Since Netbeans 6.1 for Mac OS X still comes with JDK 1.5 and I wanted 1.6 I went to Tools > Java Platforms and added 1.6 (/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home). But if I wanted to change 1.6 to the default JDK it just wasn’t possible from within Netbeans itself. Browsing the Help-section I found this interesting piece:
You can set the IDE’s default platform by running the IDE with the –jdkhome switch on the command line or by entering the path to the JDK in the netbeans_j2sdkhome property of your INSTALLATION_DIRECTORY/etc/netbeans.conf file.
Since I didn’t wanted to start Netbeans with an extra parameter I went to my Applications folder and right clicked on Netbeans 6.1.app choosing “Show Package contents”. Navigating to Contents/Resources/etc/ I found the said netbeans.conf. Inside there was this line:
# Default location of JDK, can be overridden by using --jdkhome < dir >:
netbeans_jdkhome=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home
Just changed it too /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home and restarted Netbeans et voila: 1.6 was the default JDK.
Update: In Netbeans 6.5 netbeans.conf can be found in Contents/Resources/NetBeans/etc
This is just what I was looking for.
I have been pulling my hair out for two hours.
Thank you for sharing this.
silverprince
sydney, australia
Thanks for the tip! With all the wonderful things that NetBeans can do, its amazing how a simple thing like setting the default JDK is overlooked. I use NetBeans for my java class I teach and having to change the JDK in the properties every time is REALLY annoying (almost all my students use a PC to write their code, but I use a Mac for marking).
I love the internet.
Excellent tip – this is exactly what I was after (most searches turned up results telling me how to add another platform to build/compile to – but not how to change the platform NetBeans actually runs on). Strange that you can’t do this within the IDE itself – but you’ve saved me some time! Thanks.
thanks a lot. this is what i was looking for. i tried to figure out the problem by view so many web sites by googling but no luck until i found this. thanks once again.
razi
Thank you so much. I am a .Net developer trying to learn Java. I got an excellent book ‘Murach’s Java SE6′ but until your comment I had to go changing settings for every project!!! Thank you so much!!!
Thanks. I needed this
Thnks!