JAVA_HOME and java version

I am using a Windows.bat script and I set JAVA_HOME as C:/Program Files/Java/jdk1.6.0_32 when I do java -version it still shows 1.3

How can i fix this? What am I doing wrong?

+6
source share
6 answers

Try %JAVA_HOME%\bin\java -version

If you modify JAVA_HOME , it is usually better to call java with an absolute path (using JAVA_HOME ), because the new binary is probably not in the path (and then Windows will load the wrong binary).

+6
source

Verify that the PATH environment variable points to %JAVA_HOME%\bin .

+6
source

For me, the problem was in my PATH variable, C:\ProgramData\Oracle\Java\javapath; java windows install was added before my %JAVA_HOME%\bin; . So I would echo %JAVA_HOME% point to JDK7 and java -version showing jdk8.

I would put %JAVA_HOME%\bin; to C:\ProgramData\Oracle\Java\javapath; so that java -version displays jdk7.

+4
source

Be sure not to mix the path of the system variable and the path of the system of user variables. I feel fine when calling java without an absolute path (when I know how JAVA_HOME and PATH are configured).

+1
source

Calling java -version from the command line causes cmd.exe to search the "known" directories. Known means the PATH environment variable. It seems that your PATH contains the java 1.3 bin , not 1.6.

JAVA_HOME is another variable that is used (for example, and not only) using java wrappers or scripts that execute some Java files.

Try to do this:

 SET JAVA_HOME=C:/Program Files/Java/jdk1.6.0_32 %JAVA_HOME%/bin/java -version 

Add quotation marks if necessary.

0
source

I had a similar problem, in my case I had two versions of java. it can be fixed by uninstalling one version of java completely from the system.

0
source

Source: https://habr.com/ru/post/916264/


All Articles