1

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.

soham
  • 1,508
  • 6
  • 30
  • 47
  • You'll need to put myFile.json in your JAR file. Put it in one of your packages before you build. – CaffeineToCode May 06 '15 at 17:04
  • If I want to keep that in the `resource` folder itself, is there any way out? – soham May 06 '15 at 17:19
  • http://stackoverflow.com/questions/423938/java-export-to-an-jar-file-in-eclipse – hurricane May 06 '15 at 17:22
  • @hurricane My second option is exactly that, and I am not getting external libraries and it throws error. – soham May 06 '15 at 17:24
  • Download different version of Eclipse and try with it? – hurricane May 06 '15 at 21:55
  • Using the "Export As Runnable" and a working "Launch configuration" I get a jar containing the external jars (first part of the reported question here), but the second part of including the resources dir from CLASSPATH is not working. I get warning: Jar export finished with problems. See details for additional information. Fat Jar Export: Could not find class-path entry for 'C:myProj/resource-1' Fat Jar Export: Could not find class-path entry for 'C:myProj/resource-2' These are resources in my class-path in my Launch config and work perfectly when run from Eclipse – spaniard81 Oct 16 '19 at 16:18

0 Answers0