Why is java -version returning the old version?

OS: Windows XP

I use yuicompressor-2.4.2 to compress some CSS before uploading to my server. But when I run it, the following exception appears:

  Exception in thread "main" java.lang.UnsupportedClassVersionError:
  com / yahoo / platform / yui / compressor / Bootstrap (Unsupported major.minor version 48.0) 

So I think it's because of the JRE. Command entered in cmd: java -version

And he says: the java version is "1.3.1_01", but should say "1.6.0_16" since I installed the latest version.

What if Java uses the latest version instead of the old?

+7
java
source share
8 answers

Set the JAVA_HOME environment variable pointing to the directory in which you have jdk 1.6.0

set JAVA_HOME=your_path_to_jdk1.6 set PATH=%JAVA_HOME%/bin;.;..;%PATH% 

This is from the command window. You can also do this from "My PC> Properties> Advanced> Environment variables"

+11
source share

On Windows, the JRE installs the java executable in the Windows directory, which should be the first java in your path. This is just a shell that searches the Windows registry to find the Java home directory (should be "% SystemDrive% \ Program Files \ Java \ jre6" for Java 6) and works using libraries there.

Run% SystemRoot% \ system32 \ java -version and see what you get. If it's Java 6, you have entries in your path up to% SystemRoot% \ system32 (which really should be the first). Either correct the% PATH% variable, or you must be explicit whenever you want to run this version of Java.

If starting this instance of java does not report Java 6, it is not installed (correctly). Uninstall and try installing again.

If you are having problems due to PATH, it is due to the fact that you or some software that you installed has monkeys with it; I recommend using the default value that system32 should have first. Everything works fine if the default values ​​are used.

In addition,% JAVA_HOME% is not used by the JRE itself. Some common Java applications, such as tomcat and ant, correspond to the% JAVA_HOME% setting, so perhaps yuicompressor as well. But this is a de facto agreement, not a standard.

+7
source share

Go to the system32 directory C: \ Windows \ System32 and delete the following 3 files

  • java.exe
  • javaw.exe
  • javaws.exe

Now create a JAVA_HOME environment variable with value = {root jdk installation path} and add the path to the bin folder to your jdk in the PATH environment variable.

Open a new command prompt and run java -version to confirm the change

+6
source share

You must change your PATH environment variable:

My computer> Right-click> Properties> Advanced> Environment Variables

And change the "Path"

Add the path to your 1.6 installation at the end:

 ;C:\jdk1.6.xxx\bin 

and delete the previous one, if any.

+2
source share

Add% JAVA_HOME% / bin to the PATH environment variable where JAVA_HOME is installed in the JRE6u16 directory

+1
source share

You should check the PATH environment variable. Perhaps some application that you installed has put its version of jre in front of yours on the way.

0
source share

It looks like the older version of Java is still in the system PATH environment variable (where the OS is looking for commands) or JAVA_HOME (where yuicompressor can look for the java executable)

How these variables change depends on your operating system.

0
source share

If you are using Windows 7/10, go to the command prompt and type

 where java 

Remove all symbolic links shown below, except for your actual installation directory.

0
source share

All Articles