0

I have a really basic question about ant. When I execute the build.xml file within Eclipse with

Run as -> Ant Build

Then everything works fine. However, when I try to run the same build.xml file from the command line like

ant -f build.xml

Then for same classes I get errors like:

Error: `package com.sun.image.codec.jpeg` does not exist

Any ideas, what should I do?

Thanks

Hybrid Developer
  • 2,320
  • 1
  • 34
  • 55
padre
  • 197
  • 1
  • 2
  • 8

2 Answers2

0

as its clear from the error its talking about package com.sun.image.codec.jpeg does not exist which is not present.

Whats happening in case of eclipse is that that jar/package is there in build path of project as a result of which its getting included in build process from eclipse.

As a solution try to include that jar file in build path of ant i.e. put that url in ant script and then try building the project from terminal. It should work.

Scientist
  • 1,458
  • 2
  • 15
  • 31
  • ýehp, it worked. Thanks. I put the "c:\Program Files (x86)\Java\jre7\lib\" in the build.xml file, and it worked. Is it possible to give this path as a ANT argument in the command line? I don't want to have it in the build.xml file. Thanks – padre Oct 10 '13 at 14:44
  • NO! Don't reference the JRE! Download the JDK from Oracle. Then point `%JAVA_HOME% to _that_, and put `%JAVA_HOME/bin` in front of your path before `C:\Windows\system32`. You want to make sure you're using the JDK! – David W. Oct 10 '13 at 14:58
  • Hi David, my system was already configured as you describe, but that does not solve my problem, as the library that I need i "rt.jar" is in the "lib" folder of "jre" not "jdk". The problem is that "ANT 1.9.2" does not include this library by default when building the "build.xml" file. As pointed by Tushar, when building within Eclipse, Eclipse includes this libraries, but I don't know how to point ANT to include the libraray when executed from the command line – padre Oct 11 '13 at 06:45
0

Can't tell too much from your brief description. The first question is whether this is an issue with Ant itself or your build.xml file.

Eclipse installs it's own version of Ant. I recommend you download the latest from the Ant Project page. It's version 1.9.1 or 1.9.2.

Now, let's do a simple test. Write a simple build.xml:

<project>
   <echo>Hello, world!</echo>
</project>

And, run that. If this works, the problem may be your build.xml file It might depend upon embedded Eclipse jars.

However, looking up this particular error in Grep Code, I see it's a dependency upon the Java JDK itself.

Again, Eclipse will come with an embedded JDK (it requires a JRE to run, but needs the JDK to compile). Do you have Java 1.6 or Java 1.7 JDK installed on your system? Do you have it in your path? Do you have $JAVA_HOME set on your terminal pointing to it? Is $JAVA_HOME exported (if you're using Mac or Linux or Unix)?

Try each of these things, then update your question with your findings.

David W.
  • 105,218
  • 39
  • 216
  • 337
  • it's not a problem with the ANT, I already manage to build simple programs and the ant is building a large part of my build.xml file, however, when it comes to the compilatin part, then I get this error. – padre Oct 10 '13 at 14:24
  • the questin is rather, if I can add some input parameters to the ANT such that standart java libraries can be included – padre Oct 10 '13 at 14:24
  • You shouldn't have to include standard Java libraries that are part of the JDK itself. Do you have `$JAVA_HOME` pointing to a JDK and not a JRE? What version of Ant are you using? Is it one you installed, or part of Eclipse? – David W. Oct 10 '13 at 14:57