Why does java -version return an old version?

OS: Windows XP

I am using 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.
I typed in the command:

cmd: java -version

And it says:

java version "1.3.1_01"

But it should say 1.6.0_16, since I have installed the latest version.

What should I do to make Java use the latest version instead of the old one?

Answer

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

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

That’s from a command window. Also you can do it from “My PC > Properties > Advanced > Environment variables”

Leave a Reply

Your email address will not be published. Required fields are marked *