File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes IDEs, Version Control and other tools and the fly likes ClassPath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "ClassPath" Watch "ClassPath" New topic


Rufus BugleWeed
Ranch Hand

Joined: Feb 22, 2002
Posts: 1551
Seems as though when I was getting started using ANT/Eclipse I had a classpath problem. Does ANT in Eclipse use the classpath of the environment it runs under while Eclipse uses the buildpath to create the targets?
The question that showed up from my user is
I have an Ant build.xml file that has a target, which is the default target. When I run the Ant build from the shell, the process goes smoothly and the JUnit test succeeds.
However, when I run the Ant build from inside Eclipse, I get ClassDefNotFoundErrors for javax.rmi.PortableRemoteObject.
Running the Ant build with -verbose setting, I see that the classpath being used is (linebreaks added for readability):
D:\data\Software Development\eclipse\ContactMgt\build\classes;
On inspection, I found that rt.jar contains the javax.rmi.PortableRemoteObject, and rt.jar IS on the classpath.
So in short, the same build script works fine with Ant from the command line, but not with Ant within Eclipse.
Anyone have any ideas?

We eventually got the system to work but we're not sure what we did to fix it.
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
You can get some strange compile issues from within Eclipse if you don't set the compiler to match the default eclipse compiler. Try adding this to your build.xml and setting it as a dependency on your compile step...

"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The team, Newsletter 039.
Ed Burnette
Ranch Hand

Joined: Jun 10, 2003
Posts: 142
Originally posted by Rufus BugleWeed:
Does ANT in Eclipse use the classpath of the environment it runs under while Eclipse uses the buildpath to create the targets?

First of all running Ant in Eclipse uses the same JVM that Eclipse is using. There's a new option to start up a new JVM for Ant in the 3.0 version but it's off by default because using the existing one is faster.
Next, Ant or anything else running under Eclipse doesn't use the CLASSPATH environment variable. CLASSPATH is the root of all evil so this is ok with me, but it suprises many new users. To get something on Ant's classpath, use Window > Preferences > Ant > Runtime.

Ed Burnette, Author of Hello Android
Blog: ZDNet's Dev Connection - Twitter: @eburnette
I agree. Here's the link:
subject: ClassPath
jQuery in Action, 3rd edition