Installing different versions is no problem, as long as you set CLASSPATH, JAVA_HOME and the PATH to the correct version. In Eclipse, it's just a matter of telling your IDE which one to choose. In the settings, check the Java/Installed JRE's options. You can add JREs you have installed. You can then choose which JRE to use for each project. Go to the project properties, Java Build Path, Libraries, JRE System Libraries, click Edit and choose the appropriate JRE. It's not very detailed but I hope you'll figure it out
Actually, you do not need to set the CLASSPATH and JAVA_HOME environment variables at all.
If you don't set the CLASSPATH, then Java will automatically look in the current directory for class files. You can also specify the classpath on the command line when you run a Java program by using the "-classpath" or "-cp" switch, for example:
java -cp C:\MyProject com.mycompany.MyProgram
The environment variable JAVA_HOME is not used at all by the JDK. Some other programs (like Apache Tomcat) use it to determine the location of the Java runtime environment, but it is not really necessary.
Setting the PATH is optional, this is to tell your operating system where it should look for java.exe. If you don't add the "bin" directory your Java runtime environment to the PATH, you can still run Java programs, you'll just have to type in the full path of java.exe, for example:
Goto the menu Window / Preferences..., choose Java / Installed JREs. There you can manage the JREs that you want to use with Eclipse and the projects you make in Eclipse. Also see the Eclipse help. [ June 04, 2007: Message edited by: Jesper Young ]
There's only one JAVA_HOME, one PATH, and one CLASSPATH. So you'll have to set them before compiling/running your program.
1. If you're compiling at the command line, it's useful to make a batch file containing the proper SET commands. For example, to use 1.4, in a batch file called setenv14.bat : SET JAVA_HOME=c:\j2sdk1.4.2_03 SET PATH=c:\j2sdk1.4.2_03\bin;%PATH%
To use 1.5, in another batch file called setenv15.bat : SET JAVA_HOME=c:\jdk1.5.0_09 SET PATH=c:\jdk1.5.0_09\bin;%PATH%
Before compiling/running a program, you'll have to call the appropriate batch file.
2. If you're using an IDE like Eclipse, you don't have to care to much about that. Just change the settings in Eclipse as I've written in the previous post, and Eclipse will take care of setting environment variables for you. You can have one project using 1.4, and one project using 1.5, by setting each project's properties correctly. Check the Java Build Path window in the Project Properties.
Satou, I like your approach. I have a couple batch files to switch my command line environment between versions.
For regular "production" use, I launch applications from batch files that set up path & classpath and then run java. Sometimes they get a bit longish. This one runs "stealthy" with no console output ...
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: How to install multiple JDKs and config the CLASSPTH variable