• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UnsupportedClassVersionError

 
Ja vardhan
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ja vardhan
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic