1

I need to set the Java environment variable in cmd.exe. I tried this:

set java = System.out.println(System.getProperty("java.home"));
path=java;%path%

I am aware that this does not change anything, but I thought it'd be a good start. So how could I change the Java environment variable? (The script needs to be run on Windows 7 and 8 clients.)

William
  • 266
  • 1
  • 4
  • 18

2 Answers2

1

Following command will set the JAVA_HOME environment variable. This is required if you are to install java based application such as Eclipse,Tomcat etc

SET JAVA_HOME = C:/Program Files/Java

Following command will set the PATH environment variable. This is required if you want to access java compiler(javac) and java itself.

SET PATH = %PATH%;%JAVA_HOME%\bin
zawhtut
  • 111
  • 2
-1

How about this :

set JAVA=path\to\the\desired\jdk
set PATH=%JAVA%;%PATH%

But remember that everytime you change/create an env variable, you'll see these changes only in the current cmd.exe opened.

If you want to change your jdk system wide thanks to a script, I'm not sure this is so easy on Windows.

Maxime
  • 251
  • 1
  • 2
  • 6