问题
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?
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
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.
回答1:
No, but you will need to close and recreate any cmd
windows, running java programs, or the like.
To check it's correct, open a new cmd
window and type set
-> review the information for PATH
and JAVA_HOME
.
回答2:
You should set two things:
- JAVA_HOME
- PATH
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\
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.
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:
echo %JAVA_HOME%
This should output where you set your java home variable to.
echo %PATH%
At the end of what is output, you should see your java home\bin addition to the path variable
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.
回答3:
Not necessary. Reopen a command prompt (if any) that runs the java process and type java -version
to check if it installed successfully.
回答4:
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.
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%
.
回答5:
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.
回答6:
I reinstall the JDK
and set the JAVA_HOME
and PATH
variable again. now it's working.
回答7:
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
来源:https://stackoverflow.com/questions/24307782/do-i-need-to-restart-my-system-after-setting-java-in-system-environments-path-v