wood burning stoves 2.0*
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
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
Author

Eclipse exported Jar | .getResource() not working

Glen Arthur
Greenhorn

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:

executable.jar
executable.jar/PACK/*.class
executable.jar/DATA

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
Greenhorn

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