问题
How to install both java7 and java8 in windows7 machine.
If Yes then what is the order and any switch options from java7 to java8 ?
回答1:
You can install any number of JDK
instances on your computer (and use them in projects or tools), but only one can be used as the main with JAVA_HOME
env variable and its bin
dir should be added to the PATH
value like %JAVA_HOME%\bin
.
JAVA_HOME
location is used by most software to detect default JDK
location and binaries dir in PATH
allows you to use JDK
apps like javac
in the terminal or by direct calls from anywhere
If everything is correct then you should see desired java version in terminal just typing:
C:\Users\Admin>%JAVA_HOME%/bin/java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
Linux, Mac OS X or Win installations slightly differ from each other, but you can find all the necessary instructions at the Oracle site.
回答2:
As Cootri has stated - you can install any number of Java versions on windows machines.
JAVA_HOME and PATH will be needed.
Here is a screen print showing two different java versions by invoking frm each version's bin directory
回答3:
you can install various JDK's and according to your project need you can specify the JAVA_HOME variable. if you wish to use JDK 7 for some project set your JAVA_HOME path with JDK 7 or vice-versa. say, you are using linux OS you can set it like..
export JAVA_HOME=/usr/lib/jvm/<the one which you wish to use>
来源:https://stackoverflow.com/questions/36174699/how-to-install-both-java7-and-java-8