Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

java - Should I add both JAVA_HOME and JRE_HOME in environmental variable, PATH?

I ran into this error while setting up my Tomcat and Java environmental path:

Neither the JAVA_HOME nor the JRE_HOME environmental variables is defined. At least one of the 2 environmental variables is needed to run this program.

In the user variables: I created JAVA_HOME variables and add C:Program FilesJavajdk1.8.0_25 to its path. and then did an edit of system variable PATH, added C:Program FilesJavajdk1.8.0_25; to the beginning of the its path. I also created JRE_HOME in user variable and added C:Program FilesJavajre1.8.0_25 to its path.

Is it necessary to create JRE_HOME and should I add the JRE path to the system variable also?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This answer explains all the steps with screenshots and examples

Better Use the 8.3 directory-format. In fact No spaces, ever. 8.3 naming

  1. JAVA_HOME - your JDK folder
    C:Program FilesJavajdk1.6.0_45 == C:PROGRA~1JavaJDK16~1.0_4
    C:Program FilesJavajdk1.7.0_71 == C:PROGRA~1JavaJDK17~1.0_7
    C:Program FilesJavajdk1.8.0_25 == C:PROGRA~1JavaJDK18~1.0_2
    C:Program FilesJavajdk1.9.0 == C:PROGRA~1JavaJDK19~1.0

  2. JRE_HOME
    C:Program FilesJavajre6 == C:PROGRA~1Javajre6
    C:Program FilesJavajre7 == C:PROGRA~1Javajre7
    C:Program FilesJavajre1.8.0_25 == C:PROGRA~1JavaJRE18~1.0_2
    C:Program FilesJavajre1.9.0 == C:PROGRA~1JavaJRE19~1.0

  3. Addition to PATH - best practice!

    • USE WINDOWS+R
    • Enter C:Windowssystem32systempropertiesadvanced.exe
    • Add ;C:ProgramDataOracleJavajavapath; to the end of PATH
      (System Variables not User Variables).

    • Click OK, explore to C:ProgramDataOracleJava and rename javapath folder (from C:ProgramDataOracleJavajavapath) to javapath_old.

    • Create new folder named javapath.
    • Start CMD and browse into (the now empty) C:ProgramDataOracleJavajavapath.
    • Run to create symbolic links:

      1. ln -s "C:Program FilesJavajre7injava.exe" java.exe
      2. ln -s "C:Program FilesJavajre7injavaw.exe" javaw.exe
      3. ln -s "C:Program FilesJavajre7injavaws.exe" javaws.exe

    • Done with PATH and *_HOME, now let's continue with the Windows Registry.
  4. Open up you preferred registry editor (Registry Workshop is the best), browse HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Development Kit notice all installed versions are shown as keys, double click CurrentVersion (REG_SZ value) and modify its data to your preferred SDK version, mine is 1.7 (For Android Studio) Registry edit

  5. Do the same for HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment (with CurrentVersion) Registry edit

  6. Close down java-based programs such as eclipse or IntelliJ,

    • Open up task-manager- processes tab,
    • Look for explorer.exe, cmd.exe and java(*something*).exe programs,
    • Right-click eache and click End Task (not "End Process-Tree"!)
    • Click File?New Task?enter explorer.exe
      .

The changes you've done above were applied successfully
No need to reboot, no need to log-off/on again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...