• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ant's classpath vs Eclipse's classpath

 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fellows:
I have started using eclipse this week and I'm having problems with compilations.
The project that I'm working on is quite big, it has predefined build.xml files with .properties files that declares the libraries needed for the classpath.
In eclipse, I added in my classpath all the libraries I needed to compile my code (in the same order that build.xml declares it). But, when I compile my code I get errors, complaining that a class is not defined in the classpath.
If I go to my command prompt and execute the same target, the program compiles with no problems.
Having exactly the same libraries in my classpath, I do not know what the problem might be. I have read this post and this one. On these posts, a suggestion is add this to build.xml

I have not tried this snippet (will do it tomorrow), but I'd also love not to touch build.xml at all (policies around here,specially when I'm the only one using eclipse). Is there any other workaround for this problem?
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "I added in my classpath all the libraries" - exactly which classpath are you speaking of? And how do you compile your code inside eclipse - using Ant, using the Eclipse compiler, or something else?
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ilja Preuss:
What do you mean by "I added in my classpath all the libraries" - exactly which classpath are you speaking of? And how do you compile your code inside eclipse - using Ant, using the Eclipse compiler, or something else?

My code needs a specific set of libraries to compile. I added those libraries to the classpath in eclipse.
I do not want to use eclipse for that. I want to use Ant (which is integrated in eclipse) for compilation purposes. What I'm saying is that compilation is successful when compiling my code using the same build.xml, with the same libraries in the command prompt. But if I use the IDE, it throws errors.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andres Gonzalez:
My code needs a specific set of libraries to compile. I added those libraries to the classpath in eclipse.

And I don't understand what you mean by this, sorry. How did you do it?

I do not want to use eclipse for that. I want to use Ant (which is integrated in eclipse) for compilation purposes. What I'm saying is that compilation is successful when compiling my code using the same build.xml, with the same libraries in the command prompt. But if I use the IDE, it throws errors.

What errors do you get? Can you show us the relevant parts of the build script?
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ilja -
In build.xml you can specify properties. I have a properties called {libraries} that points to jar files that are needed in order to compile the code successfully. This is a post I submitted in the eclipse mailing list:

(Notice the classpath pointing to my {libraries} properties)
Using this target in the command prompt results in *successful* compilation.
However, if I try running the the same task inside eclipse, it throws
a compiler error, something like:
"This compilation unit indirectly references the missing type
javax.transaction.SystemException (typically some required class file is
referencing a type outside the classpath)"
I have added the *same* libraries that I have in my {libraries} into
eclipse's classpath, as well as the ant runtime classpath (in the same
order as well), but I can't get this to work. I have also checked where SystemException file is located and is indeed in one of the jar files that I have in the classpath

</blockquote>
hope it's now clear, this is so frustrating
[ October 28, 2003: Message edited by: Andres Gonzalez ]
[ October 28, 2003: Message edited by: Andres Gonzalez ]
[ October 28, 2003: Message edited by: Andres Gonzalez ]
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you can see, I have tried many ways posting the target, but javaranch doesn't like it anyway, even if I put it inside a code block, a quote code, etc.. it is something like this
javac srcdir="${src}" destdir="${build}" classpath="${libraries}"
[ October 28, 2003: Message edited by: Andres Gonzalez ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see. Does your classpath in ${libraries} include *relative* paths?
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ilja Preuss:
I see. Does your classpath in ${libraries} include *relative* paths?

hmm .. good point... they're declared like this:
property name="libraries" value="../lib/common/myFirst.jar;../lib/mySecond.zip;.....
BTW, my directory structure is :
D:\source\myProject\src
D:\source\myProject\lib
..
..
build.xml is located on myProject folder. So, in command line, i position myself in d:\source\myProject and use ant targets with no problems.
my base dir in build.xml is : basedir="."
In eclipse, when I right click on my project to see the properties, this is what I get:
path: /myProject
Location: d:\source\myProject
hmm that might be the reason, shouldn't the path be /source/myProject?
thanks again
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm .. that couldn't be the problem... otherwise the whole code wouldn't compile. It's just this single class that is breaking everything off, even though it's in the classpath.
Another suggestion from the eclipse forum *itself* was to use ant outside eclipse, specially when the project is big (my case).
I miss intelij
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic