When trying to export a project as a .jar
file, Eclipse will complain that some files can't be found on the classpath:
Class files on classpath not found or not accessible for: 'proj/src/main/java/analysis/specification/VerifyVariableIsDefinedInsideTargetTerm.java'
Now, the interesting part is that these files haven't actually existed on the disk for ages. I guess I force Eclipse to refresh its database some way. I've tried doing F5 for a full build, but it seems to no avail. I've also tried the procedure described in this blog post, but the issue remains.
Error… I actually tripped on the reason for the problem a few moments ago…
All the files that were raising problems did actually exist on the project but were commented out (and thus, I didn't see them in the package explorer which is the view I generally use).
After deleting them, everything went fine. I still don't understand why would they raise errors in the JAR creation process, though…
EDIT: Here's an example of a commented out class:
package a.b.c
//import java.io.Closeable;
//public class Example implements Closeable {
// public void close() throws IOException {
// System.out.println("closed");
// }
//}
Because the whole class is commented out, no Example.class
is created. Whereas if the class is commented out like this:
package a.b.c
//import java.io.Closeable;
public class Example
// implements Closeable
{
// public void close() throws IOException {
// System.out.println("closed");
// }
}
an Example.class
is created, although empty.
This may be a bug in eclipse. If you export the ant build script from eclipse and use that, it creates the JAR just fine.
This issue occurred to me also. However, the problem that I had was that I had JRE configuration issues in Eclipse.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With