how to control which version of jdk Netbeans uses

Posted on 2007-10-05
Last Modified: 2010-05-18

i am using the latest netbeans ide to build a simple jms java file,

but i am getting this:

Compiling 10 source files to

C:\wrox\pro_jms\Chapter04\ package

javax.jms does not exist
import javax.jms.*;
C:\wrox\pro_jms\Chapter04\ cannot find

the netbeans ide i am using uses jdk_1.6, which when i use directly

to compile in command line mode, works.  can anyone tell me why this

is happening?

also, if possible, can someone tell me how to get Netbeans to switch

from jdk_1.6 to jdk1.4?  i tried modifying the JAVA_HOME env

variable, but didn't work.
Question by:mmingfeilam
    LVL 7

    Accepted Solution


    To change jdk version that NetBeans use change contents of file:

    C:\Program Files\netbeans-5.5.1\etc\netbeans.conf
    (exact netbeans directory name depends on which version of netbeans you're using)

    On my computer, contents of this file is:

    # ${HOME} will be replaced by JVM user.home system property

    # options used by netbeans launcher by default, can be overridden by explicit
    # command line switches
    netbeans_default_options="-J-Xms32m -J-Xmx128m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true"
    # --- tips for more advanced options you could use ---
    # for JDKs where it is supported (for example Sun's JDK 5.0 and newer),
    # you can use the following set of options which enable Concurrent Mark and
    # Sweep garbage collection algorithm and improve UI responsiveness
    # (see FAQ item
    #netbeans_default_options="-J-Xms32m -J-Xmx128m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled"
    # if you're processing large wsdl files(e.g. when creating or consuming web services) you should set -J-Xmx256m instead of -J-Xmx128m
    # ---

    # default location of J2SE JDK, can be overridden by using --jdkhome <dir> switch
    netbeans_jdkhome="C:\Program Files\Java\jdk1.6.0_02"

    # clusters' paths separated by path.separator (semicolon on Windows, colon on Unices)

    You need to change just the string "C:\Program Files\Java\jdk1.6.0_02" (in your case it will be something else) to the directory of jdk which you want to use.


    Author Comment

    thanks. but now during netbeans startup, it's complaining about not being to install:
    JUnit Tests, Web Services Core, etc.  because java 1.5 was requested but only 1.4 is running.
    LVL 4

    Assisted Solution


    i think this will help u a lot


    Author Comment

    thanks for all your help, i just found out the netbeans 5.5 only accept jdk 1.5 or above, so i had to use netbeans 5.0.  but i still can't figure out why even when i was using netbeans 5.5, i can compile jms code:

    javax.jms does not exist
    import javax.jms.*;

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now