This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes How to use the JRE I want, to launch my program when I have two JDKS installed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to use the JRE I want, to launch my program when I have two JDKS installed?" Watch "How to use the JRE I want, to launch my program when I have two JDKS installed?" New topic
Author

How to use the JRE I want, to launch my program when I have two JDKS installed?

Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
I have JDK 6 and JDK 5 installed.I can use the preferred compiler by setting the path at the time of compiling But How do I use the preferred JRE to run a program using the "java" command?


Varuna Seneviratna
Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
The Matter resolved, By setting the path it is possible to invoke the preferred JRE and the Compiler both.But if the path is not set at the time of compiling, the JRE that is invoked by typing "java" at the command prompt is the JRE that was installed with the first JDK installed.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3826

But if the path is not set at the time of compiling, the JRE that is invoked by typing "java" at the command prompt is the JRE that was installed with the first JDK installed

How do you define the "first JDK installation" here? In general it's the first to appear in the path is picked. And you can check the version used by java by typing java -version. For this, of course you should have set the path appropriately or be in the JDK/bin directory or use the exact path to the JDK/bin.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38465
    
  23
Maybe better to write the full path when you invoke "java" . . . or similar. Saves problems later when you have forgotten what you changed the system PATH to. You may need "" if there is a space in the PATH
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to use the JRE I want, to launch my program when I have two JDKS installed?