File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes Classpath Build Order Changes (entries in .classpath file keep becoming reset) 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 Build Order Changes (entries in .classpath file keep becoming reset)" Watch "Classpath Build Order Changes (entries in .classpath file keep becoming reset)" New topic
Author

Classpath Build Order Changes (entries in .classpath file keep becoming reset)

James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
I am using Eclipse3.5 JEE 64 bit on OS X Snow Leopard.

Was wondering how the .classpath file's <classpathentry> tag's order gets changed everytime I run a standard Ant build script.

When I manually change the build path order like this (via Eclipse):

(1) Right click on project in Project Explorer.

(2) A context menu opens up

(3) Go to Build Path

(4) Configure Build Path

(5) Click on the Java Build Path Order and Export Tab

(6) Modified the order to look like this:

myproject/work/src (moved this to the top)
myproject/work/test/unit
myproject/work/impl/src (this is a linked resource which points to a 2nd Eclipse project which is open in Eclipse at the same time)

The myproject/work/impl/src by default is at the first position for the order. Manually moved myproject/work/src to the top (by clicking on the Up button).

When I run my build script, it seems that the .classpath file (which this order is written to behind-the-scenes) is reset to how it was before:



Why is this? Where and when does Eclipse modify the .classpath file? How can it be set so people can change the build order manually through Eclipse but the .classpath's build order never gets reset to its defaults? After setting this and building the project by right mouse clicking on my project (not the impl one) and going to Build Project, the order never gets changed. It only resets when the Ant build script is run.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

I used to play with stuff like that. I don't anymore, although that's largely because Maven makes the idea pretty much meaningless.

Although it can be aesthetically appealing to order your classpath entries "just so", in actuality, if the order that you have your classpath entries specified is critical, then you have a problem. I'm not even sure if the Java spec specifies that classpath entries have to be searched in a linear sequence, but Java wasn't intended to allow overriding class retrieval by shifting around classpath entries. In fact, that could be considered a security issue. So in the normal course of events, there should be one and only one copy of each class in the classpath, making the actual physical ordering of classpath entries a moot point.


Customer surveys are for companies who didn't pay proper attention to begin with.
James Dekker
Ranch Hand

Joined: Dec 09, 2006
Posts: 215
Hi Tim,

Actually not... Classpath ordering is very important when you have 2 different projects open in Eclipse and link both projects to each other as Shared Resources.

Either way, I found the properties file which changes everything and its now fixed. I now can just build the top project and the impl gets moved over.

Thank you for taking the time to read this.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16012
    
  19

Actually that sounds more like dependency ordering than classpath ordering.
Tushar Patidar
Greenhorn

Joined: May 01, 2011
Posts: 1
where is that property file in eclipse
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Classpath Build Order Changes (entries in .classpath file keep becoming reset)