简体   繁体   English

如何从Windows的Shell脚本配置JAVA_HOME

[英]How to configure JAVA_HOME from Windows at shell script

I want to run a jar file from shell script. 我想从shell脚本运行jar文件。 But current operating system is Windows. 但是当前的操作系统是Windows。 So, how to configure to know JAVA_HOME in shell script. 因此,如何配置以在Shell脚本中了解JAVA_HOME I want to know how to export JAVA_HOME from Windows in shell script. 我想知道如何在shell脚本中从Windows导出JAVA_HOME 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: Windows中JDK路径是C:\\Program Files\\Java\\jdk1.6.0_32\\bin\\java运行外壳程序时,出现以下错误:

Files\\Java\\jdk1.6.0_32: command not found Files \\ Java \\ jdk1.6.0_32:找不到命令

The path to your JDK = JAVA_HOME is C:\\Program Files\\Java\\jdk1.6.0_32 . 您的JDK = JAVA_HOME的路径是C:\\Program Files\\Java\\jdk1.6.0_32 You have to add %JAVA_HOME%\\bin to PATH. 您必须将%JAVA_HOME%\\bin添加到PATH。

These lines could be part of your shell script: 这些行可能是您的Shell脚本的一部分:

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. 尽管可以从脚本中设置这些变量,但是在Windows上,通常的方法是在计算机范围内进行设置。

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 添加一个名称为JAVA_HOME且值为C:\\Program Files\\Java\\jdk1.6.0_32

Find the PATH variable and append ;%JAVA_HOME\\bin (including the semicolon) to it. 找到PATH变量,然后将;%JAVA_HOME\\bin (包括分号)附加到该变量。

More detailed instructions on setting path and environment variables on Windows are available here http://www.computerhope.com/issues/ch000549.htm 有关在Windows上设置路径和环境变量的更多详细说明,请参见http://www.computerhope.com/issues/ch000549.htm。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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