Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to restart my system after setting JAVA in system environment's path variable?

Tags:

java

java-home

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.
like image 418
Sandeep vashisth Avatar asked Jun 19 '14 13:06

Sandeep vashisth


People also ask

Do I need to restart my computer after installing Java?

A: Rebooting is sometimes required because Microsoft Windows Installer, the technology used by the Java installer, requires it. In addition, some Java files could be locked and cannot be replaced without a reboot.

Is it necessary to set Java environment variables?

Java does not need any environment variables to be set. However, setting some environment variables makes some things easier. PATH If the jre/bin folder is on the path, you don't have to qualify to run the java command. If the jdk/bin folder is on the path, you don't have to qualify to run the java and javac commands.

What environment variables should be set for Java?

JAVA_HOME and PATH are variables to enable your operating system to find required Java programs and utilities.


3 Answers

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.

like image 65
vikingsteve Avatar answered Oct 18 '22 07:10

vikingsteve


You should set two things:

  1. JAVA_HOME
  2. 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.

like image 42
Mike Elofson Avatar answered Oct 18 '22 08:10

Mike Elofson


Not necessary. Quit and Open the command prompt again (if any) that runs the java process and type java -version to check if it installed successfully.

If you are using mac, source ~/.bashrc or source ~/.zshrc should refresh your environmental variable. No need to re-start the terminal even.

like image 24
SparkOn Avatar answered Oct 18 '22 07:10

SparkOn