Resources access problem from JAR
- by aeter
I have the following directory structure of a project:
Folder "project" in Eclipse:
--folder "src"
--folder "resources"
----trayicon2.png
--folder "db"
----test.db
--folder "bin"
I'm accessing the image with:
Image image = Toolkit.getDefaultToolkit().getImage("resources/trayicon2.png");
and from Eclipse that is not a problem.
Then I generate an "executable jar file", and add the dirs, making a directory structure of:
Folder "project"
--folder "db"
----test.db
--folder "resources"
----trayicon2.png
--project.jar
And now the image is no more accessible. Also, the database is no more accessible; while in Eclipse I used to access it with:
Connection conn = DriverManager.getConnection("jdbc:sqlite:db/test.db");
How can I access the resources (images and db) after generating the jar file "project.jar"?