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?
If the program uses a batch to start, then add this line before the start of the program:
SET JAVA_HOME="C:\Program Files\Java7\Java.exe"
(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:
@echo off
SET JAVA_HOME=...
ThisIsMyFancyScalaProgram.Exe
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:
SET JAVA_HOME="C:\Program Files\Java7\Java.exe"
(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:
@echo off
SET JAVA_HOME=...
ThisIsMyFancyScalaProgram.Exe
To Add system environment variables:
setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0"
setx PATH "%PATH%;%JAVA_HOME%\bin";
To update system environment variables:
setx -m JAVA_HOME "C:\Program Files\Java\jdk1.8.0"
setx -m PATH "%PATH%;%JAVA_HOME%\bin";
© 2022 - 2024 — McMap. All rights reserved.