Should I add JAVA_HOME and JRE_HOME to the PATH environment variable?

I ran into this error when setting up my Tomcat and Java migration path:

Neither JAVA_HOME nor JRE_HOME environment variables are defined. At least one of the two environment variables is required to run this program.

In user variables: I created JAVA_HOME variables and added C: \ Program Files \ Java \ jdk1.8.0_25 to my path. and then edited the PATH system variable by adding C: \ Program Files \ Java \ jdk1.8.0_25; to the beginning of his journey. I also created JRE_HOME in a user variable and added C: \ Program Files \ Java \ jre1.8.0_25 to my path.

Do I need to create a JRE_HOME and add a JRE path to the system variable?

+5
java tomcat8
Jan 17 '15 at 5:49
source share
4 answers

This answer explains all the steps with screenshots and examples.

Better use the 8.3 directory format. There are actually no spaces. 8.3 naming

  • JAVA_HOME - JDK folder

    C:\Program Files\Java\jdk1.6.0_45 == C:\PROGRA~1\Java\JDK16~1.0_4
    C:\Program Files\Java\jdk1.7.0_71 == C:\PROGRA~1\Java\JDK17~1.0_7
    C:\Program Files\Java\jdk1.8.0_25 == C:\PROGRA~1\Java\JDK18~1.0_2
    C:\Program Files\Java\jdk1.9.0 == C:\PROGRA~1\Java\JDK19~1.0

  • JRE_HOME
    C:\Program Files\Java\jre6 == C:\PROGRA~1\Java\jre6
    C:\Program Files\Java\jre7 == C:\PROGRA~1\Java\jre7
    C:\Program Files\Java\jre1.8.0_25 == C:\PROGRA~1\Java\JRE18~1.0_2
    C:\Program Files\Java\jre1.9.0 == C:\PROGRA~1\Java\JRE19~1.0

  • PATH add-on is best practice!

    • USING WINDOWS + R
    • Type C:\Windows\system32\systempropertiesadvanced.exe
    • Add ;C:\ProgramData\Oracle\Java\javapath; at the end of PATH
      (System variables, not user variables).

    • Click OK, open C:\ProgramData\Oracle\Java\ and rename the javapath folder (from C:\ProgramData\Oracle\Java\javapath\ ) to javapath_old .

    • Create a new folder named javapath .
    • Launch CMD and browse (now empty) C:\ProgramData\Oracle\Java\javapath\ .
    • Run to create symbolic links:

      • ln -s "C:\Program Files\Java\jre7\bin\java.exe" java.exe
      • ln -s "C:\Program Files\Java\jre7\bin\javaw.exe" javaw.exe
      • ln -s "C:\Program Files\Java\jre7\bin\javaws.exe" javaws.exe

    • Done with PATH and *_HOME , now you can continue to work with the Windows registry.
  • Open your preferred registry editor ( "Registry Workshop" is the best), look at the HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit notification that all installed versions are shown as, double-click CurrentVersion (REG_SZ value) and change its data to the preferred version of the SDK, mine is 1.7 (for Android Studio ) Registry edit

  • Do the same for HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment (with CurrentVersion ) Registry edit

  • Quit Java programs such as eclipse or IntelliJ ,

    • Open the process manager process tab,
    • Look for the programs explorer.exe , cmd.exe and java(*something*).exe ,
    • Right-click eache and click "End Task" (not "End Process Tree"!)
    • Click FileNew Task ➩enter explorer.exe
      .

The changes you made above have been successfully applied
There is no need to reboot, there is no need to log out again.

+11
Jan 11 '16 at 23:47
source share

You really don't need to add JRE_HOME to system variables. Tomcat is looking for JAVA_HOME or JRE_HOME to get started. This is because tomcat requires some java library to start running. Tomcat will provide an additional debugging feature if Jdk is provided instead of Jre. More information here

Adding {JAVA_HOME_DIR}/bin to your path will allow you to access java from anywhere.

+2
Jan 17 '15 at 6:05
source share

Try it...

For Java ,

In user variables add PATH value C:\Program Files\Java\jdk1.8.0_25\bin;

For tomcat

In the system variables add JAVA_HOME value C:\Program Files\Java\jdk1.8.0_25

Now the class path has been installed on your computer. You can access java from anywhere on your computer.

After doing this, go to Command Prompt and go to ApacheTomcat * xx and go to the bin folder,

Start server

 startup.bat 

To check the status of Tomcat’s work, go to your browser and Paste the URL,

http: // localhost: 8080 /

Stop server

 shutdown.bat 
+1
Jan 17 '15 at 5:57
source share

After changing the system variables, it is important to open a new console window

0
Nov 11 '15 at 7:30
source share



All Articles