I am having problems with Eclipse projects. I make a new Java project and in the 'Java Build Path --> Libraries' specify a jar file (Any jar file, for example - axis.jar). I click ok and then import certain code that references the package org.apache.axis. Eclipse marks these references as Compilation Errors. Per my understanding, I should not get compilation errors since the jar file (axis.jar) is present in my 'Libraries' (in effect being present on my Classpath). Is my understanding incorrect? Am I missing something here?
After struggling for a long time with this, I experimented some more and did a 'File --> Import --> archive file'. I imported the axis.jar this way - and it exploded the axis.jar file into individual packages into my project's workspace. This resolves my compilation problem. But, I still don't like the clutter of the individual packages in my project's workspace.
You have a project. You right click the project and select properties. Select Java Build Path. Select Libraries. Click the Add Jar button. Select a jar file. Click ok and ok again.
The jar file now shows up in the in the top level of the package explorer with a little jar looking icon next to it. If you've done all that and still are getting compile errors I would first do a 'project > clean' to get a clean compile, and then look at the fully qualified name in the import where it shows as a compile error and make sure that class does indeed exist in the jar you imported.
Joined: Aug 01, 2001
Hi Steve, Thanks for your reply.
Although your comments were extremely helpful in improving my understanding of Eclipse, the problem was somewhere else. After I had referenced my libraries - I guess Eclipse automatically references them in the classpath for that project. When I did the import of the file system, my file system contained a classpath that was overwriting the original classpath of the project thereby deleting the references created, earlier.
The problem got resolved when I explicitly asked Eclipse not to overwrite my existing classpath.
I thought I will just write the resolution in case this is helpful to anyone in the future.