Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do we need to set Windows environment variables for Java updates anymore?

Tags:

java

windows

I've been setting Windows environment variables (like JAVA_HOME) every time I installed a Java update. (As per Environment variables for java installation).

However, I've recently noticed that Java updates add C:\ProgramData\Oracle\Java\javapath; to the System Path (not the User Path). I removed JAVA_HOME, etc from my User Path, and java -version seems to work from any directory.

Does that mean that it is not necessary to do that simple but annoying task with each Java update?

like image 656
George Hernandez Avatar asked Jan 25 '18 19:01

George Hernandez


People also ask

Is it mandatory to set environment variable for Java?

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.

Do we need to set environment variables for JRE?

After you've installed Java in Windows, you must set the JAVA_HOME environment variable to point to the Java installation directory. This information is only relevant if you're installing Confluence manually on a Windows server.

Why do we set environment variables in Windows for Java?

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

Are environment variables needed?

Environment variables not recommended for every situation Environment variables provide a good way to set application execution parameters that are used by processes that you do not have direct control over. However, environment variables should not be used for configuration values within your own dynamic applications.


2 Answers

That depends on what you are trying to do.

Generally, you don't need JAVA_HOME to run a Java app. Adding the location of the Java binaries to the PATH is sufficient for Windows to find and execute them.

However, e.g. a lot of application servers like Tomcat and build tools like Gradle will use JAVA_HOME to determine the location of your Java installation.

like image 146
TimoStaudinger Avatar answered Sep 25 '22 11:09

TimoStaudinger


Java itself does not use JAVA_HOME. Some third-party things like IDEs and Tomcat do. I've never set it as an environment variable in 20 years.

like image 38
user207421 Avatar answered Sep 24 '22 11:09

user207421