jQuery in Action, 3rd edition
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse exported Jar | .getResource() not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse exported Jar | .getResource() not working" Watch "Eclipse exported Jar | .getResource() not working" New topic

Eclipse exported Jar | .getResource() not working

Glen Arthur

Joined: Apr 12, 2012
Posts: 2

Hi all,

I have a source directory called DIR. Data contains a large 130Mb file called DATA (35Mb when its exported to an executable Jar).

In the src directory, I have a package called PACK, and it contains a main method and a bunch of classes. One of those classes reads the file from data using

DATA is set to export to the default path, which is /bin.
When launching from Eclipse, Eclipse creates an absolute path (it prints "Path: /C:/__/__/bin/DATA" and "Type: plain/text"), and the applications runs great.

When export exporting my project to an executable jar, Eclipse generates a jar file resembling:


java -jar C:/__/__/executable.jar
Does not work (it prints "Path: DATA" and "Type: null"). It cannot read the file.

As you guessed these are not the real names. Here is the content of the manifest file in case it helps.

Manifest-Version: 1.0
Rsrc-Class-Path: ./ protobuf-java-2.4.1-lite.jar
Class-Path: .
Rsrc-Main-Class: blue.BlueMile
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

I have wasted a whole day on this one issue of getting the application to read the content of the file from the executable jar. I have also tried JarFile(String) instead of File(String) with same error. Please help.
Glen Arthur

Joined: Apr 12, 2012
Posts: 2

I realised the fix. How annoying.

I agree. Here's the link: http://aspose.com/file-tools
subject: Eclipse exported Jar | .getResource() not working
It's not a secret anymore!