Netbeans and default JDK

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 entry was posted in Programming and tagged , , , . Bookmark the permalink.

7 Responses to Netbeans and default JDK

  1. silverprince says:

    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

  2. the sarcastic programmer says:

    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.

  3. Babble On says:

    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.

  4. rizwan says:

    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

  5. Brian O'Sullivan says:

    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!!!

  6. Osagie says:

    Thanks. I needed this

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>