This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipse exported Jar | .getResource() not working

 
Glen Arthur
Greenhorn
Posts: 2
Google Web Toolkit Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
Google Web Toolkit Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I realised the fix. How annoying.



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic