views:

260

answers:

2

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??

A: 

Use the variable set by the Java Installer instead:

set path="%path%;%JAVA_HOME%\bin"
mhaller
+1  A: 

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

OscarRyz