设置为Java库时出错 [英] Error while setting to Java library
问题描述
我通过命令将JAVA_HOME设置为Java主目录的完整路径:
C:\ Users \trainee7> setx JAVA_HOME" C:\\ \\ Program Files\Java \ _jdk1.6.0_21"
,结果是:
SUCCESS :保存了指定值。
我确认后输入命令:
C:\ Users \trainee7>%JAVA_HOME% \ bin \ _java -version
但它不起作用,结果为错误:
C:\程序''不被识别为内部或外部命令,
可操作程序或批处理文件。
为什么这个?我怎样才能将JAVA_HOME设置为java库?
I set JAVA_HOME to the full path of the Java home directory by command :
C:\Users\trainee7>setx JAVA_HOME "C:\Program Files\Java\jdk1.6.0_21"
and result was:
SUCCESS: Specified value was saved.
After I for confirmation I entered command :
C:\Users\trainee7>%JAVA_HOME%\bin\java -version
but it doesn''t work, got result as error :
C:\Program'' is not recognized as an internal or external command,
operable program or batch file.
Why this? And what can I do for setting JAVA_HOME to java library?
推荐答案
我自己没有使用setx,而是 http://ss64.com/nt/setx.html [ ^ ]说:
I haven''t used "setx" myself but a doc page at http://ss64.com/nt/setx.html[^] says:
由于SETX将变量写入注册表中的主环境,因此编辑仅在打开新命令窗口时生效 - 它们不会影响当前的CMD或PowerShell会话。
Because SETX writes variables to the master environment in the registry, edits will only take effect when a new command window is opened - they do not affect the current CMD or PowerShell session.
换句话说,在使用''setx''设置值后,您需要丢弃您所在的窗口并打开一个新窗口。
In other words, after setting the value with ''setx'', you need to discard the window you are in and open a new one.
C:\ Users \trainee7>%JAVA_HOME%\ bin \ _java -version
C:\Users\trainee7>"%JAVA_HOME%"\bin\java -version
这篇关于设置为Java库时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!