Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Java path in command line for only one directory

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?

like image 897
slumpmonkey Avatar asked Jun 15 '15 21:06

slumpmonkey


1 Answers

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.

like image 149
Razib Avatar answered Oct 31 '22 02:10

Razib