Forum Stats

  • 3,875,862 Users
  • 2,266,977 Discussions


WJ-3141A Lab Question

843789 Member Posts: 46,655 Green Ribbon
I am trying to compile Exercise 2 using Apache Ant as instructed in the course. I am having problems w/ javac versioning and I know nothing about Ant or how it decides which javac version to use, etc. I would really like some help w/o having to read the entire Ant manual and become an expert in Ant just to get through this one simple exercise. Please help. I've downloaded Apache TomCat Webserver 5.0, Apache Ant 1.7, and I already had Java JDK 1.5.0_06 w/ JRE update 1.5.0_10.

I do have a Java SDK1.3.1_02 installed for another app but my JAVA_HOME is set to JDK1.5.0_06. The command I execute is "ant compileWebapp". The error I get is below:

[javac] Compiling 2 source files to C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\dvd\WEB-INF\classes
[javac] C:\Documents and Settings\jcwaters\My Documents\Personal\programming\java\SunWLC\labs\SL314\exercises\project\src\model\ cannot access java.lang.Object
[javac] bad class file: C:\Program Files\Java\jdk1.5.0_06\jre\lib\rt.jar(java/lang/Object.class)
[javac] class file has wrong version 49.0, should be 47.0
[javac] Please remove or make sure it appears in the correct subdirectory of the classpath.
[javac] public class DVDItem implements {
[javac] ^
[javac] 1 error

C:\Documents and Settings\jcwaters\My Documents\Personal\programming\java\SunWLC\labs\SL314\exercises\project\build.xml:51: Compile failed; see the compiler error output for details.

Total time: 2 seconds


  • 796447
    796447 Member Posts: 10,442
    When you type:
    java -version
    at the command-line, what does it say the version is?

    I bet it's finding version 1.3 (of the javac compiler, at least) in your PATH before it finds 1.5, so that's the one it is executing
  • 843789
    843789 Member Posts: 46,655 Green Ribbon
    java version "1.5.0_10" and for what it is worth the file compiles w/ "javac" but not w/ ant. Someone suggested there is an "executable" attribute for the ant javac core task and I can see it listed in the manual under "Ant Tasks" but I have no idea where to set it or what to set it to be (or if that is even my problem).
  • 796447
    796447 Member Posts: 10,442
    I wouldn't mess with the javac core task. It just still looks like somehow it is picking up the 1.3 version to compile with.

    When you say you run javac from the command-line, do you happen to be in the 1.5 bin directory when you do that? If so, that would force it to run the 1.5 version. I hope instead you are running it from the same directory where you're running ant.

    You didn't modify ant's batch file did you? It should try to use JAVA_HOME to find the version of java to run, or failing that, try from the PATH. Are you sure for sure for sure JAVA_HOME is set to the 1.5 directory?

    When you run javac from the command-line, you're not using JAVA_HOME - just the PATH.
  • 843789
    843789 Member Posts: 46,655 Green Ribbon
    y dont u try compiling it in comand prompt and see if it works there
  • 843789
    843789 Member Posts: 46,655 Green Ribbon
    Yes it compiles using javac from a command line. The javac version used from a command line is the 1.5.0_10 version. Does anyone know what Ant is doing differently to cause it not to compile?
This discussion has been closed.