• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Not able to compile java files with Ant

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have been trying to resolve this problem for over a week now and I'm really hoping someone here will be able to help me.

I am working on a automated build/deploy application. This application extracts code from cvs for the main project and dependent projects. The dependent projects need to be compiled and made into jars. This issue I am having is in the ant <javac> command. When the command is called, the java files are found but errors get thrown because all of the dependent packages/imports are not being seen.

I have added absolute paths to those packages but errors are still thrown. For instance here is my <javac> code:

<target name="compileJavaJar" >
<echo message="compiling LMIG_logging" />
<javac srcdir="${src.dir}" destdir="${outputDir}"
classpath="C:/workspace/ReferenceBuildProcess/extract/LMIG_logging/lib/commons-logging.jar, C:/workspace/ReferenceBuildProcess/extract/LMIG_logging/lib/log4j-1.2.8.jar,
C:/workspace/ReferenceBuildProcess/extract/LMIG_logging/lib/xml-apis.jar
C:/workspace/ReferenceBuildProcess/extract/LMIG_logging/lib/commons-logging-api.jar" >
</javac>
</target>

compileJavaJar:
[echo] compiling LMIG_logging
[javac] Compiling 1 source file to C:\workspace\ReferenceBuildProcess\extract\LMIG_logging\src\com\lmig\common\logging
[javac] C:\workspace\ReferenceBuildProcess\extract\LMIG_logging\src\com\lmig\common\logging\LogFactory.java:8: cannot resolve symbol
[javac] symbol : class DOMConfigurator
[javac] location: package xml
[javac] import org.apache.log4j.xml.DOMConfigurator;
[javac] ^
[javac] C:\workspace\ReferenceBuildProcess\extract\LMIG_logging\src\com\lmig\common\logging\LogFactory.java:29: cannot resolve symbol
[javac] symbol : variable DOMConfigurator
[javac] location: class com.lmig.common.logging.LogFactory
[javac] DOMConfigurator.configureAndWatch("/properties/log4j.xml");
[javac] ^
[javac] 2 errors

Here's my problem: The import statement that it's looking for is located within log4j-1.2.8.jar but it's not seeing it to allow the file to compile, is there any reason why this could happen? What do I need to do to resolve this? I'm assuming that it is a classpath issue but I've run out of ideas. There are other projects that I'm trying to work on as well and they don't recognize anything on their classpaths.

Any help at all would be very much appreciated.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deb

I have just done a similar thing and that worked fine for me.

You seem to be using a package of apache. You probably did not include that in one of the jars (correct me if i am wrong. Make sure you include that on the classpath as well.

If that is not it, here are two more things to check:

Are you sure, that at the moment you start compiling, the bytecode of log4j-1.2.8.jar is in the specified path? (i.e., in C:/workspace/ReferenceBuildProcess/extract/LMIG_logging/lib/ )

If you compile your code direct from the cvs code, you have to be aware that the order in which you compile is important. (you should then compile log4j-1.2.8.jar before commons-logging.jar)

Good luck !
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem might also be in how you list the classpath elements in

<target name="compileJavaJar" >
<echo message="compiling LMIG_logging" />
<javac srcdir="${src.dir}" destdir="${outputDir}"
classpath="C:/workspace/ReferenceBuildProcess/extract/LMIG_logging/lib/commons-logging.jar, C:/workspace/ReferenceBuildProcess/extract/LMIG_logging/lib/log4j-1.2.8.jar,
C:/workspace/ReferenceBuildProcess/extract/LMIG_logging/lib/xml-apis.jar
C:/workspace/ReferenceBuildProcess/extract/LMIG_logging/lib/commons-logging-api.jar" >


I believe Ant expects ";" or ":" as the path separator, not "," as you have here.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'd be better off using an embedded <classpath> element with <fileset> elements, as opposed to the classpath attribute. It gives you more flexibility, and is less prone to delimiter errors.
 
reply
    Bookmark Topic Watch Topic
  • New Topic