aspose file tools*
The moose likes Beginning Java and the fly likes UnsupportedClassVersionError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "UnsupportedClassVersionError" Watch "UnsupportedClassVersionError" New topic
Author

UnsupportedClassVersionError

Ja vardhan
Ranch Hand

Joined: May 09, 2005
Posts: 169
Hi Folks,

I am getting this 'UnsupportedClassVersionError' when trying to run
'ant compile' command. For this compile task, the build.xml file contains:

<target name="compile">
<mkdir dir="build/classes"/>
<javac srcdir="src" destdir="build/classes"/>
</target>

'scr' directory having small HelloWOrld.java.
Initially I thought the problem is because of PATH settings to various versiond of JRE, so I checked that and its fine. When am trying to compile & run that HelloWorld.java with javac & java its working fine.

I am getting error only with 'ant compile' command.

I am pretty new to this ANT. Please give me any suggestions or solutions...

Thnx.


Javardhan:
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Check that your JAVA_HOME and/or JAVAHOME environment variables are consistent with your PATH (i.e., the version of Java pointed to by JAVAHOME is the same one as is found in the PATH) and also makes sure you don't have any version of jre/lib/rt.jar mentioned on your CLASSPATH environment variable.


[Jess in Action][AskingGoodQuestions]
Ja vardhan
Ranch Hand

Joined: May 09, 2005
Posts: 169
Hi Hill,

Thnanks for ur reply.

I checked out that JAVA_HOME and PATH variables, they are pointing to same version only. If they are ponting to differant versions, how can I compile and run with javac and java ?? What I mean to say is now am able to compile my program with javac, the problem is when am using 'ant compile' command.
I am also able to see rt.jar under jre/lib. Hope no problem with this also.
(Its beter if you tell me the purpose of rt.jar)

Any other suggestions pls.
Rajasekar Kayamboo
Greenhorn

Joined: Sep 04, 2003
Posts: 9
Try to un install all other JRE or JDK. Clean up your PATH and CLASPATH. Alternatively, set your PATH and CLASSPATH in your build.xml and then proceed.
regards,


Sekar
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
It sounds like you have (or had) two different versions of Java installed. Perhaps you can run "ant clean" first and then try "ant compile" again. Of course, this assumes that your Ant script has a target named "clean" that removes the .class files from a previous compile.

Layne


Java API Documentation
The Java Tutorial
 
jQuery in Action, 2nd edition
 
subject: UnsupportedClassVersionError