24

I want to install JDK 1.5 and 1.6 on XP, is it possible? how to do it

Also, I am using Eclipse how to setup using different JDK for different projects?

thanks.

1
  • 3
    By the way, this is exactly the same procedure on Windows 2000, XP, Vista and Windows 7 so it's not particular to XP. May 20, 2009 at 8:17

5 Answers 5

27

You may install different JDKs easily: just specify different folders.

You can setup the installed JDKs in Eclipse Window/Preferences/Installed JREs

You can pick the JDK and Java version for every single project in Project/Properties/Java Compiler

3
  • 5
    No, Sun will only always see the last version you installed. Also, you can install, copy the directory somewhere and then uninstall. Java doesn't need the registry keys to work. Just set JAVA_HOME and it'll work. May 20, 2009 at 8:40
  • +1 for being terse yet complete, helpful & useful. Note: Oracle's installer will overwrite the JRE folder by default. i.e. for Java 6 it will prompt you to change from the default Java/jre6, but this complicates setup. Interesting that Oracle's installer supports by default different JDK subfolders (e.g. jdk1.6.0_37, jdk1.6.0_45) but only one JRE subfulder.
    – Withheld
    Aug 13, 2014 at 18:17
  • Don't forget, if you're going to be running Java programs from the console, you will also need to set the PATH. Please just have one of the java binaries set on the PATH.
    – NomadMaker
    Dec 8, 2020 at 13:11
12

I have solved this by creating batch files for different Java versions.

  1. I have installed the Java versions I need to have
  2. Whenever, I need to use Java I run the appropriate batch file and set the environment variables to work with that Java version.

Java 8.bat

@echo off
echo Setting JAVA_HOME
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
echo setting PATH
set PATH=%JAVA_HOME%\bin;%PATH%
echo Display java version
java -version

Java 10.bat

@echo off
echo Setting JAVA_HOME
set JAVA_HOME=C:\Program Files\Java\jdk-10.0.2
echo setting PATH
set PATH=%JAVA_HOME%\bin;%PATH%
echo Display java version
java -version
1

Why? There is an option (can't remember where exactly - right-click on your project) that allows you to set the target JDK level. I use this when developing GWT applications.

1
  • The only nuance is that in few cases the Java API will differ as new methods are introduced and class interfaces change. Fortunately the README "4. Running Eclipse" covers how to select a JDK.
    – Daniel
    May 23, 2013 at 18:59
1

Try using sdkman. Even though the installing on Windows is a bit 'tricky' but there are several options.

https://sdkman.io/install

0

There was a big mess with different incompatible JDK and JRE from 90s when Java was created and still this problem exists. The main rule is when you type in console:

java -version

and

javac -version

the result should be the same then you sure both JRE and JDK (JSDK) are compatible, so when you compile you can rut it without any problems.

JAVA_HOME and PATH are essential for many console applications and some GUI tools might use those variables as well but often is possible to alter default settings in GUI application instead of messing with environment variables. Also CLASSPATH still sometimes are used as well, however better use ANT as compiler than javac directly.

You can install multiple JDK and JRE but each one should to have its own separate folder, the default should be usually ok.

Worth mentioning that every JDK have JRE included and it instal in separate folder and as separate APP in Windows Control Panel -> Applications to be more confusing, so basically developer will never have to download and install JRE. Do not use Java update application which might cause problems after update some apps might not work, just do it manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.