views:

156

answers:

5

I'm having a problem with imports in one of my java applications.

I've Taken a working JSP out of one Eclipse project, Jar'd up all the classes from that project and put it into a new project.

In the new Project I've imported the jar file generated from the original, and pasted the jsp code into a new JSP document.

I'm getting "The import XX could not be resolved errors".

Anyone one have any idea how to diagnose this, everything seems to be in order.

+1  A: 

When you say "I've imported the jar file" you mean you have copied it or put it in the classpath?

Valentin Jacquemin
It's in the build path of the project. (In the properties of the project)
Omar Kooheji
+4  A: 

I have an issue like this once in awhile. Try removing the JAR, rebuilding, and adding the JAR again. This should fix it.

It's an Eclipse bug.

Edit: The above answer is assuming the jar is actually on the build path.

Zack
I was skeptical but that worked... I'm not sure why...
Omar Kooheji
I'm not sure. As a side note, I've noticed these issues also with bringing in jars: When I add something to the build path and then add it as a java EE module dependency, I often have to manually build the project before republishing (glassfish v2). However, if I just go into "Java EE Module dependencies" and add it as an external jar there, it automatically builds after every save. Just another quirk. Not sure if others have this issue.
Zack
A: 

When you add a Jar file, instead of Import, right click on the project and choose "Add External Library" or "Add External Jar"

ferrari fan
A: 

It sounds like the jar you imported doesn't appear in your build path. Try right-clicking the project, select Build Path > Add External Archives...

This should put a reference to your jar in the project build path.

highlycaffeinated
A: 

Check inside the Jar (just open it from the build path) and see if the paths are correct. If you have foo.Bar as something else than foo/Bar.class that might be it.

Thorbjørn Ravn Andersen