java – Should I add both JAVA_HOME and JRE_HOME in environmental variable, PATH?
java – Should I add both JAVA_HOME and JRE_HOME in environmental variable, PATH?
This answer explains all the steps with screenshots and examples
Better Use the 8.3 directory-format. In fact No spaces, ever.
-
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
-
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
-
Addition to
PATH
– best practice!- USE WINDOWS+R
- Enter
C:Windowssystem32systempropertiesadvanced.exe
-
Add
;C:ProgramDataOracleJavajavapath;
to the end ofPATH
(System Variables not User Variables).
-
Click OK, explore to
C:ProgramDataOracleJava
and renamejavapath
folder (fromC:ProgramDataOracleJavajavapath
) tojavapath_old
. - Create new folder named
javapath
. - Start CMD and browse into (the now empty)
C:ProgramDataOracleJavajavapath
. -
Run to create symbolic links:
ln -s C:Program FilesJavajre7binjava.exe java.exe
ln -s C:Program FilesJavajre7binjavaw.exe javaw.exe
ln -s C:Program FilesJavajre7binjavaws.exe javaws.exe
- Done with
PATH
and*_HOME
, now lets continue with the Windows Registry.
-
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 clickCurrentVersion
(REG_SZ value) and modify its data to your preferred SDK version, mine is 1.7 (For Android Studio)
-
Do the same for
HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment
(withCurrentVersion
)
-
Close down java-based programs such as eclipse or IntelliJ,
- Open up task-manager- processes tab,
- Look for
explorer.exe
,cmd.exe
andjava(*something*).exe
programs, - Right-click eache and click End Task (not End Process-Tree!)
- Click
File
➩New Task
➩enterexplorer.exe
.
The changes youve done above were applied successfully
No need to reboot, no need to log-off/on again.
You really do not need to add JRE_HOME
to the system variables. Tomcat looks for JAVA_HOME
or JRE_HOME
to get itself start. This is because tomcat require some java library to get itself started. Tomcat will provide additional debugging functionality if Jdk is provided instead of Jre. Additional details here
Adding {JAVA_HOME_DIR}/bin
to your path would enable to access java from anywhere.
java – Should I add both JAVA_HOME and JRE_HOME in environmental variable, PATH?
Try this…
For Java,
In the User variables, add PATH
value is C:Program FilesJavajdk1.8.0_25bin;
For Tomcat
In the System variables, add JAVA_HOME
value is C:Program FilesJavajdk1.8.0_25
Now classpath has been set to your machine. You can access java from anywhere in your machine.
After Done this, Go to Command Prompt
and go to ApacheTomcat*x.x and move to bin
folder,,
Start the Server
startup.bat
For check Tomcat running status, Go to your browser, and Paste the URL,
Stop the Server
shutdown.bat