• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with getClass().getResource in jar?  RSS feed

 
Marcus Hathaway
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

In my code i have this line:



Basically this folder contains images. The code above finds this folder and then finds all the images etc for later use.

When testing in eclipse this works great. However when everything gets put into a jar file it stops working

Is there a reason why that code would stop working in a jar file? I've checked the jar and the images package does seem to get created correctly.

For refrence, if the code above is in the package - com.test, the images package is in com.test.images.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cant get it as a File, but you can access resources in the jar as either a URL or as a stream for reading.

Dave
 
Marcus Hathaway
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh ok. Thanks Dave will try a different approach
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!