Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to export any of my projects into a .jar file

Everytime I try to export any of the projects from my workspace into a Java jar file, I end up with an error:

JAR creation failed. See details for additional information. Class files on classpath not found or not accessible for: 'Server Manager/src/me/Zahach/ServerManager/main.java'

And this error is repeated for every class in my project.

I tried reinstalling Eclipse, that didn't work. I then tried to recreate a project and drag and drop my packages into it, that didn't work either.

What is going on?

like image 827
Papos Avatar asked Aug 24 '14 15:08

Papos


People also ask

How do I export a jar file?

To export your project, right-click it and select Export. Select Java > Runnable JAR file as the export destination and click Next. On the next page, specify the name and path of the JAR file to create and select the Launch configuration that includes the project name and the name of the test class.

How do I repair a corrupt jar file?

Try use the command jar -xvf fileName. jar and then do export the content of the decompressed file into a new Java project into Eclipse. Save this answer.


2 Answers

The error is caused because of a missing .class file(s) for corresponding .java file(s)

  1. In Eclipse

    Goto Project->Clean and Rebuild the Project and then try exporting,
    If it doesn't work then make sure .class file exists in the bin folder for main.java file in your case

  2. Another solution is to ensure that the Classpath is Valid

like image 96
Ravi Yenugu Avatar answered Oct 20 '22 22:10

Ravi Yenugu


Also make sure that the permissions in your workspace folders are ok. I ran into this problem after updating Eclipse and then downloading some Maven dependencies. In the end, what fixed it was doing a sudo chmod 777 -R workspace/MyProject

like image 27
alexandru.asandei89 Avatar answered Oct 20 '22 23:10

alexandru.asandei89