在系统环境的路径变量中设置 JAVA 后是否需要重新启动系统?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24307782/
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
Do I need to restart my system after setting JAVA in system environment's path variable?
提问by Sandeep vashisth
I did the following steps but java does not seem to be working for me, do I need to restart my system if yes then why?
我执行了以下步骤,但 java 似乎对我不起作用,如果是,我是否需要重新启动系统,那为什么?
1. Right click My Computer->Advence Option->Environment Varibles->System Variables
2. variable : Path->Edit
3. Copy your jdk bin directory i.e.C:\Program Files\Java\jdk1.7.0_51\bin
4. Paste it after putting a semi-colon(;) in value section
i am getting below error while running java in cmd
在 cmd 中运行 java 时出现以下错误
C:\Users\User>java -version
Error: opening registry key 'Software\JavaSoft\Java Runtime Environment'
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.
采纳答案by vikingsteve
No, but you will need to close and recreate any cmd
windows, running java programs, or the like.
不,但您需要关闭并重新创建任何cmd
窗口、运行 Java 程序等。
To check it's correct, open a new cmd
window and type set
-> review the information for PATH
and JAVA_HOME
.
要检查它是正确的,打开一个新的cmd
窗口,然后键入set
- >的信息PATH
和JAVA_HOME
。
回答by SparkOn
Not necessary. Reopen a command prompt (if any) that runs the java process and type java -version
to check if it installed successfully.
没有必要。重新打开运行 java 进程的命令提示符(如果有)并键入java -version
以检查它是否安装成功。
回答by Mandar Pandit
NO.
You don't need to restart the system, but just the application like cmd
or any IDE you are using for java development (i.e Eclipse) need to restart.
不。
您不需要重新启动系统,只是需要重新启动类似应用程序cmd
或您用于 Java 开发的任何 IDE(即 Eclipse)。
And to confirm that the java path is set that you have mentioned in JAVA_HOME environment variable, you can open cmd
and you can check with commands echo %JAVA_HOME%
or echo %PATH%
.
并确认您在 JAVA_HOME 环境变量中提到的 java 路径已设置,您可以打开cmd
并使用命令echo %JAVA_HOME%
或echo %PATH%
.
回答by Mike Elofson
You should set two things:
你应该设置两件事:
- JAVA_HOME
- PATH
- JAVA_HOME
- 小路
The first lies under the "User variables for [your user name]" section. Add the JAVA_HOME variable and set it to where your jdk is installed. i.e. C:\Program Files\Java\jdk1.7.0_51\
第一个位于“[您的用户名] 的用户变量”部分。添加 JAVA_HOME 变量并将其设置为安装 jdk 的位置。即 C:\Program Files\Java\jdk1.7.0_51\
The second lies under the "System variables" section. You should find the "path" variable, and edit it. Then, append ";%JAVA_HOME%\bin" (minus the quotes) to the end of the path variable.
第二个位于“系统变量”部分下。您应该找到“路径”变量,并对其进行编辑。然后,将“;%JAVA_HOME%\bin”(减去引号)附加到路径变量的末尾。
After you have done this, save the variables and close that window clicking the "ok" button. Close down all instances of the command prompt (and any IDE you may be developing with such as Eclipse or NetBeans), and reopen one command prompt. Then, if you would like to test whether or not your changes worked and are in effect, try the following:
完成此操作后,保存变量并单击“确定”按钮关闭该窗口。关闭命令提示符的所有实例(以及您可能正在使用的任何 IDE,例如 Eclipse 或 NetBeans),然后重新打开一个命令提示符。然后,如果您想测试您的更改是否有效,请尝试以下操作:
echo %JAVA_HOME%
This should output where you set your java home variable to.
这应该输出您将 java home 变量设置到的位置。
echo %PATH%
At the end of what is output, you should see your java home\bin addition to the path variable
在输出的末尾,您应该看到除了路径变量之外的 java home\bin
java -version
If you can run this command from the command line, it means that your environment was set up correctly and java is now in your path.
如果您可以从命令行运行此命令,则意味着您的环境已正确设置并且 java 现在在您的路径中。
回答by Sandeep vashisth
I reinstall the JDK
and set the JAVA_HOME
and PATH
variable again. now it's working.
我重新安装并再次JDK
设置JAVA_HOME
和PATH
变量。现在它的工作。
回答by Sayed Naweed
No, you don't need to restart your system. However, you have to restart your command prompt application to update the changes done on Environment variables.
不,您不需要重新启动系统。但是,您必须重新启动命令提示符应用程序以更新对环境变量所做的更改。
回答by user11111262
In my case under user variable section(for particularuser) JAVA_HOME set to jre not jdk path . I change it to JDK path , It worked for me
在我的情况下,在用户变量部分(对于特定用户) JAVA_HOME 设置为 jre 而不是 jdk path 。我将其更改为 JDK 路径,它对我有用