Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update Windows path variable when Java is updated automatically?

This question asks how to setup your path variable in Windows to include the Java bin directory allowing you to use the javac command from the prompt. The solution posted to this question states you should hard code the absolute path of the latest Java installation.

In this case it happens to be c:\program files\java\jdk1.6.0_16\bin

I believe once Java update 17, 18 and beyond are installed your javac cmd will still be using this older version, correct?

Am I missing something?? Is there a way to set this to automatically use the most recent installed java update??

like image 342
Mark Norgren Avatar asked Nov 06 '09 22:11

Mark Norgren


People also ask

How do I check if Java environment variable is set in Windows?

Verify JAVA_HOMEOpen a Command Prompt window (Win⊞ + R, type cmd, hit Enter). Enter the command echo %JAVA_HOME% . This should output the path to your Java installation folder. If it doesn't, your JAVA_HOME variable was not set correctly.


1 Answers

I believe once Java update 17, 18 and beyond are installed your javac cmd will still be using this older version, correct?

Correct. When java is update, what get's updated is the JRE ( java runtime environment )

That automatically set your java plugin ( used in the browser ) and your java command set to the latest version. ( Open a terminal and type java -version )

The SDK ( Java SDK ) which contains the javac is not changed. You have to do it manually.

One option is do what mhaller says.

I go further using the environment variables in Windows.

MyPC/RigthClick/Properties/Advaced/EnvironmentVariables/

From there I add JAVA_HOME poiting to the desired JDK path ( c:\jsdk_x_x_x ) and set the PATH variable to:

 whatever;_it_had;_before;%JAVA_HOME%\bin

Is there a way to set this to automatically use the most recent installed java update??

For the JRE it would be automatically set, for the SDK you'll only need to modify the system variables and change the value of JAVA_HOME

like image 185
OscarRyz Avatar answered Oct 04 '22 15:10

OscarRyz