mercredi 6 mai 2015

How do I export a project in Eclipse to jar with both external libraries and resources?

My project in eclipse has both resources in res folder and external libraries. I tried two options to export the project as an executable jar.

1) I tried to export it using the Export -> Runnable Jar option. However, when I run the jar, I get the resource file not found exception/error.

When I tried to export it I get the following warning:

Fat Jar Export: Could not find class-path entry for 'home/../res'

I selected the option Package required libraries into generared JAR.

So, my problem here is that I can't include my resource folder with this option. Specific line problem is that: myClass.class.getResourceAsStream("/myFile.json").

2) Secondly I tried exporting with Export -> JAR file. Now, I can't include the external libraries that I am using. I can include the resource folder by selecting resources to export. However, there's no option to include external libraries. I tried Export all output folders for checked projects. When I run the generated JAR file, I get java.lang.NoClassDefFoundError error.

So, my questions is how can I include both the external libraries and the resource folder I am using to export my project as jar in Eclipse.

Aucun commentaire:

Enregistrer un commentaire