I am running a program that utilizes Scala 2.10 for work and is not compatible with Java 8, only Java 7. In a Windows 7 command line, how can I set the java path to use Java 7 ONLY for that directory?
Set Java path in command line for only one directory
13.5k views Asked by slumpmonkey At
3
There are 3 answers
0
On
You may create 2 batch file one for java 7 and one for java 8 like this -
jdk7.bat
@echo off
echo Setting JAVA_HOME
set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_11
echo setting PATH
set PATH=C:\Program Files\Java\jdk1.7.0_11\bin;%PATH%
echo Display java version
java -version
jdk8.bat
@echo off
echo Setting JAVA_HOME
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_11
echo setting PATH
set PATH=C:\Program Files\Java\jdk1.7.8_11\bin;%PATH%
echo Display java version
java -version
You may quickly switch between them running these batch file.
If the program uses a batch to start, then add this line before the start of the program:
(This is just an example, the directory might be different on your computer)
If the program does not use such a batch (you can recognize it because it ends with either .cmd or .bat) create such a file and use that for launching the program instead: