Forum Stats

  • 3,853,821 Users
  • 2,264,280 Discussions
  • 7,905,459 Comments

Discussions

setting Java home for two java versions

rickepm
rickepm Member Posts: 536
edited Mar 6, 2015 10:53AM in New To Java

Hi All ..

I have two java versions installed on my system .

1) java 6 in C drive

2)java 7 in D drive

I need to know if I can get a option to use any of these 2 java versions when I launch my app..

Right now its taking 2) by default , though in my user variable I have set it to 1) ..

Can any one please tell how I can fix this issue ..

Should I edit the path file and then add the 1) at the beginning so that my app picks up that..or shall I make a variable Jr AVA_HOME1 and JAVA_HOME2 , but then which one my app will call first .

or can I set something in my Java console that asks me to browse to the java location of my choice.

Thanks

Best Answer

  • Unknown
    edited Mar 6, 2015 10:53AM Answer ✓
    I have two java versions installed on my system .
    1) java 6 in C drive
    2)java 7 in D drive
    
    I need to know if I can get a option to use any of these 2 java versions when I launch my app..
    Right now its taking 2) by default , though in my user variable I have set it to 1) ..
    
    Can any one please tell how I can fix this issue ..
    
    

    Just create a simple batch file that sets the PATH by adding the version you want to use to it and then launches your app.

    If you want you can pass a parameter to the batch file to tell it which version to use.

Answers

  • PhHein
    PhHein Member, Moderator Posts: 7,245 Silver Trophy
    edited Mar 6, 2015 8:09AM

    When running a Java app, the path variable is used to find the java.exe file. Update your path to java 6. If you want to run a Java app with Java 7 you just specify the full path:

    d:> d:\path_toJava_7\bin\java.exe YourApp

  • Unknown
    edited Mar 6, 2015 10:53AM Answer ✓
    I have two java versions installed on my system .
    1) java 6 in C drive
    2)java 7 in D drive
    
    I need to know if I can get a option to use any of these 2 java versions when I launch my app..
    Right now its taking 2) by default , though in my user variable I have set it to 1) ..
    
    Can any one please tell how I can fix this issue ..
    
    

    Just create a simple batch file that sets the PATH by adding the version you want to use to it and then launches your app.

    If you want you can pass a parameter to the batch file to tell it which version to use.

This discussion has been closed.