Java: export to an .jar file in eclipse

JavaEclipseExecutableExtractExe

Java Problem Overview


I'm trying to export a program in Eclipse to a jar file.

In my project I have added some pictures and PDF:s. When I'm exporting to jar file, it seems that only the main has been compiled and exported.

My will is to export everything to a jar file if it's possible, because then I want to convert it to an extraditable file, like .exe-file.

But how?

Java Solutions


Solution 1 - Java

No need for external plugins. In the Export JAR dialog, make sure you select all the necessary resources you want to export. By default, there should be no problem exporting other resource files as well (pictures, configuration files, etc...), see screenshot below. JAR Export Dialog

Solution 2 - Java

Go to file->export->JAR file, there you may select "Export generated class files and sources" and make sure that your project is selected, and all folder under there are also! Good luck!

Solution 3 - Java

FatJar can help you in this case.

In addition to the"Export as Jar" function which is included to Eclipse the Plug-In bundles all dependent JARs together into one executable jar.
The Plug-In adds the Entry "Build Fat Jar" to the Context-Menu of Java-projects

This is useful if your final exported jar includes other external jars.

If you have Ganymede, the Export Jar dialog is enough to export your resources from your project.

After Ganymede, you have:

Export Jar

Solution 4 - Java

One more option is WinRun4J. There is an Eclipse Plugin for WinRun4J that allows you to export your application as a single executable with necessary jars/classes embedded.

(full disclosure: I work on this project)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAdisView Question on Stackoverflow
Solution 1 - JavaYuval AdamView Answer on Stackoverflow
Solution 2 - JavasantiView Answer on Stackoverflow
Solution 3 - JavaVonCView Answer on Stackoverflow
Solution 4 - JavaPeter SmithView Answer on Stackoverflow