Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a problem is i can export my project to jar file to can run at other machine.

although exporting is ok but my jar file can't load images and config file and extend lib,

my project as - src
- gui
- image.

please help me!

Thanks in advance
Posted

1 solution

Hello,

Your code is not able to load resources may be because you are not using standard resourbundle API's. Your code may be using absolute path. Tre changing code to use one of the following methods to load the resource.


  • this.getClass().getResource() (or getResourceAsStream())
  • Thread.currentThread().getContextClassLoader().getResource(name)
  • System.class.getResource(name)


As far as dependant jars in lib folder are concerned you need to construct the MANIFEST.MF to have Class-Path attribute. The value of this attribute specifies the relative URLs of the extensions or libraries that this application or extension needs. URLs are separated by one or more spaces. The application or extension class loader uses the value of this attribute to construct its internal search path. More details on this can be found here.

regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900