简体   繁体   中英

How to configure JAVA_HOME from Windows at shell script

I want to run a jar file from shell script. But current operating system is Windows. So, how to configure to know JAVA_HOME in shell script. I want to know how to export JAVA_HOME from Windows in shell script. Path for JDK in Windows is C:\\Program Files\\Java\\jdk1.6.0_32\\bin\\java When I run shell program I got the following error:

Files\\Java\\jdk1.6.0_32: command not found

The path to your JDK = JAVA_HOME is C:\\Program Files\\Java\\jdk1.6.0_32 . You have to add %JAVA_HOME%\\bin to PATH.

These lines could be part of your shell script:

set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_32
set PATH=%PATH%;%JAVA_HOME%\bin

Although you can set these variables from a script, on Windows the normal way is to set them machine-wide.

Right-click on your computer icon in explorer. Select "Properties", then "Advanced System Settings", then "Environment Variables".

Add a variable with the name JAVA_HOME and the value C:\\Program Files\\Java\\jdk1.6.0_32

Find the PATH variable and append ;%JAVA_HOME\\bin (including the semicolon) to it.

More detailed instructions on setting path and environment variables on Windows are available here http://www.computerhope.com/issues/ch000549.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM