Java image loading doesnt show up in jar


I created a small image loading application, it just loads a .png inside the res folder. In eclipse running it will just work fine. But when i export it to an jar the image isnt included in the jar, so it cant load it. I tried to add the res folder to the source path and it will include the image, but it includes it in the root off the folder (Wich isnt where the image is supposed to be in) Does anyone have an idea how i can add the res folder in the jar? It does load the image when i manually (With Lubuntus archivemanager) put the res folder in the jar.

Any ideas how i can add it in the jar with eclipse?


You are on the right track when trying to make your "res" folder a java source folder. If you'd like to preserve "res" in the final path of the resources in the JAR, the res folder must sit inside a folder that's designated as the source folder.

You can either move res folder under your src folder or create a parent folder to hold res...

Option 1:

src (source folder) .. res .. .. image.png

Option 2:

src (source folder) resources (source folder) .. res .. .. image.png


If you chose the "Export -> JAR File" option, you can select all folders and files you want to include. Those will be included properly, i.e. with their full name.

If you chose the "Export -> Runnable JAR file" option, this is not possible. In that case you can save the export script as an ANT build file. In the build file you can edit the export target to include the res folder and its contents.

That being said, in the long run, for making releases/JARs, Eclipses built-in functionality is pathetic. You really want to go the ant/maven way. It takes a bit of reading, but after that it's all automatic and far less hassle and far more flexible than anything Eclipse offers.


  • .net detect distributed transaction
  • Can I keep my Core data store on the Bundle if its readonly
  • Returning from inside for loop causes type mismatch
  • iAd works in iPhone but not iPad
  • mfc - MessageBox with rich text
  • Simplifying the use of meshgrid in Matlab
  • How to call MoveDataTableCursor in a web test plugin to go through a limited set of rows in a table?
  • What's the alternative to IValueFormatter in AutoMapper?
  • How to enable Drag a Marker (Android Map Api v2) after a single Touch?
  • How do I fix “The program issued a command but the command length is incorrect.” error when calling
  • touchstart in JavaScript no longer returns TouchList
  • Error Processing Request: Mage registry key “_singleton/inchoo_notes/feed_updates” already exists
  • What exactly is the height of modalPresentationStyle - FormSheet on iPad?
  • Meteor.. accounts- password— Create account on client without login
  • How do I check if System::Collections:ArrayList is empty / nullptr / null?
  • why calling cd shell command through system() or execvp() from a child process won't work?
  • extjs4 catching the scroll event on panel
  • KnockoutObservableArray with typed elements in TypeScript
  • there is no graph with tensorboard
  • How do I display a dialog that asks the user multi-choice questıon using tkInter?
  • how does System.Web.HttpRequest::PathInfo work?
  • JBoss External Properties Files in Classpath
  • What and where is mdimport
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • htaccess add www if not subdomain, if subdomain remove www
  • Word Open XML Mail Merge
  • Test if a set exists before trying to drop it
  • Chrome doesn't support silverlight anymore? How to solve this?
  • Java: can you cast Class into a specific interface?
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Read text file and split every line in MSBuild
  • C# - Serializing and deserializing static member
  • Get object from AWS S3 as a stream
  • AES padding and writing the ciphertext to a disk file
  • Java applet as stand-alone Windows application?
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • Error creating VM instance in Google Compute Engine
  • How to get Windows thread pool to call class member function?
  • How can i traverse a binary tree from right to left in java?