Exporting Java project as .jar file will complain that certain .java files aren't found

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.

Tags:

Java

Eclipse