3

I am on widows and also using eclipse. Currently I am using java 7. Now I want to use java 8. but i cannot uninstall java 7 as some of my old projects are working in java 7.

So how can I install both java version at same time and switch between these versions.

I want only some particular projects will use java 8.

1

4 Answers 4

8

Well after installing both JDK 7 & JDK 8, There are two scenarios.

1) If you are using Eclipse to run your program

In Eclipse just go to project->Properties->java complier->set compliance level to 1.8 or 1.7 accordingly

2) If you are running your program using Command Prompt

In this case, you have to enter following commands before compiling your program

  set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_102
  set PATH=C:\Program Files\Java\jdk1.8.0_102\bin;%PATH%
  java -version

you can also make a batch file of the same. just copy and paste to notepad and save it with the .bat extension

Sign up to request clarification or add additional context in comments.

Comments

4

Create a script that changes the JAVA_HOME environment accordingly, for example:

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

Source: https://blogs.oracle.com/pranav/entry/switch_between_different_jdk_v

Comments

2

Install both JDKs in your system and for any project if you want to use jdk 1.8. Do this

Right click on that project->Properties->java complier->set compliance level to 1.8

Comments

0

If you are using Eclipse, you can set the compiler preferences with the Java version you want to use for every project.

Go to Window -> Preferences -> Java -> Compiler and there you can change the Java version.

This way, you can update your PC to Java 8 and you'll have no problem with the older projects.

1 Comment

Well, first of all you have to install Java 8. Then, you'll have the option to select the 1.8 version. You can also set the jre on `Run -> Run configurations´ on the JRE tab.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.