Seems like you not putting your stuff in the right sense. In order to make it work, follow these steps :
- Right-Click your
Project
inProject Explorer Tree
. - Go to
New -> Source Folder
and then provide anyName
to theSource Folder
. - Now manually add your stuff to this
Source Folder
so created by you, like if you want to add images then make aNew Folder
, by manually visiting thisSource Folder
throughFile System
. - Name this
New Folder
asimages
and copy your images to thisFolder
. - Now go back to your Eclipse IDE and
Refresh
yourProject
from the Project Explorer, by Right Clicking your Project, here you be able to see your added content now after refreshing.
Now in order to access, say any image, you will use.
getClass().getResource("/images/yourImageName.extension");
which will return one URL object. Do remember the first forward slash
, in this case, since whatever is inside your Source Folder is accessed with the help of this, in simpler terms. Now when you will Run your project, the content of this Source Folder will be automatically added to the bin folder and when you will create a Runnable Jar, then the stuff inside your Source Folder can be accessed as it is.