19

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?

2
  • 1
    Can you post the output of echo %path%? Commented Oct 14, 2009 at 15:55
  • You have at least 2 versions of java installed. Remove the unwanted versions. Make sure $PATH only contains your preferred version. Commented Nov 1, 2011 at 18:15

11 Answers 11

23

If you are using windows 7/10 go to command prompt and type

where java

Delete all the symbolic link shows below other than your actual installation directory.

Even if correctly added all the environment variables still sometime you can get wrong versions especially when you have multiple version installed in your system and want to switch between them.

For example : run the command

where java

then it will return something like :

C:\Program Files\Common Files\Oracle\Java\javapath 
C:\Program Files\Java\jdk-21.0.02\bin\java.exe

then delete

C:\Program Files\Common Files\Oracle\Java\javapath 

Make sure to restart the terminal after this.

Sign up to request clarification or add additional context in comments.

Comments

21

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"

2 Comments

Thanks that worked. =) But i still don't know how when I updated java it didn't change the version automatically :S
It might work, but I think it's a kludge. You shouldn't need to mess with the path if your system is set up correctly.
15

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

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

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

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

3 Comments

this can be also in this directory C:\ProgramData\Oracle\Java\javapath you need to delete them also
I also had to uninstall java from Windows parameters > Add or remove programs
In my case there was a shortcut to originally installed Java at C:\Program Files (x86)\Common Files\Oracle\Java as javapath. To find out from where java is being served you can use @Masood Moghini's answer below that shows a way to list all the java installations using command where java
10

after where java in Command prompt
for example

where java
C:\Program Files\Common Files\Oracle\Java\javapath
C:\Program Files\Java\jdk-11.0.10\bin\java.exe

delete C:\Program Files\Common Files\Oracle folder then close all terminals and write java -version in the terminal. it will show the right version
worked for me

Comments

9

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

Run %SystemRoot%\system32\java -version and see what you get. If that is Java 6, you have entries in your path before %SystemRoot%\system32 (which really should be first). Either fix your %PATH% variable, or you'll have to be explicit whenever you want to run this version of Java.

If running that instance of java doesn't report Java 6, its not installed (correctly). Uninstall and try installing again.

If you are having trouble because of the PATH, it is because you or some software you installed monkeyed with it; I recommend using the default which is to have system32 first. Everything works fine if the defaults are used.

Also, %JAVA_HOME% is not used by the JRE itself at all. Some common Java applications like tomcat and ant honor the %JAVA_HOME% setting, so perhaps yuicompressor does too. But this is a de facto convention, not a standard.

1 Comment

Awesome tip!! I never thought about this at all. I had added to my path but at the end. As soon as I adjusted the orders it resolved the issue right away. Thanks :)
2

You should modify your PATH environment variable:

My PC > Right click > properties > Advanced > Environment variables

And modify "Path"

Append at the end the path to your 1.6 installation:

;C:\jdk1.6.xxx\bin

and remove the previous one if present.

Comments

2

first by the following command, you should be aware of .exe file which runs when you type java in the command prompt

where java
C:\Program Files\Common Files\Oracle\Java\javapath
C:\Program Files\Java\jdk-11.0.10\bin\java.exe

as you see above , cmd first reads java from

C:\Program Files\Common Files\Oracle\Java\javapath

so go to the path above and remove java files . then it should work fine

Comments

1

Add %JAVA_HOME%/bin to your PATH environment variable where JAVA_HOME is set to your JRE6u16 directory

Comments

1

I had the same problem. In System Properties > Environment Variables > System Variables > PATH make sure there is no other path associated with Java. To make sure, type in and check Java paths.

where java

Re-open Command Prompt and type java -version again. I hope this helps.

Comments

0

You should check your PATH environment variable. It is possible that some application you have installed has put its version of the jre in front of yours in the path.

Comments

0

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

How those variables are changed depends on your operating system.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.