使用命令提示符在 Windows 中设置 JAVA_OPTS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24177188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 10:37:51  来源:igfitidea点击:

Setting JAVA_OPTS in windows using command prompt

javajava-opts

提问by user1907849

I am running the java program on windows server 2012, I want to set the JAVA_OPTS variable and use it, here is how I am doing it:

我在 windows server 2012 上运行 java 程序,我想设置 JAVA_OPTS 变量并使用它,这是我的做法:

Open a command prompt in the bin of jdk where it is installed ,and executing the following command :

在安装 jdk 的 bin 中打开命令提示符,并执行以下命令:

$set JAVA_OPTS = “-Xdebug , server=y”

Then in the next line in the command prompt only , when I try to run

然后在命令提示符的下一行中,当我尝试运行时

$java $JAVA_OPTS –cp .Server

(where Server is the name of the java program), I get an error saying that: Could not find or load assembly $JAVA_OPTS. Please let me know what mistake I am doing here. I am not using IDE for this purpose.

(其中 Server 是 java 程序的名称),我收到一条错误消息:无法找到或加载程序集 $JAVA_OPTS。请让我知道我在这里犯了什么错误。我不是为此目的使用 IDE。

采纳答案by Jens

on windows you have to set the variable like:

在 Windows 上,您必须设置变量,如:

set JAVA_OPTS = “-Xdebug , server=y”

and use it this way

并以这种方式使用它

java %JAVA_OPTS% –cp .Server

回答by Khanna111

Windows uses "%JAVA_OPTS% rather than "$JAVA_OPTS" which is UNIX/LINUX. You can check if the environment is updated with JAVA_OPTS by echoing that: echo %JAVA_OPTS%.

Windows 使用 "%JAVA_OPTS% 而不是 "$JAVA_OPTS",后者是 UNIX/LINUX。您可以通过回显:echo %JAVA_OPTS% 来检查环境是否使用 JAVA_OPTS 更新。