Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting resource folder with jar

Tags:

java

jar

I have a folder called "resources" in my Eclipse project. It's used as source folder. Everything works well compiled from Eclipse. I wanted to try it on Ubuntu so I exported it to runnable jar and tried to run but it gave me FileNotFound Exception. I checked the file structure inside the JAR and there's no "resources" folder, only files that should be inside. I'm accessing files with

File file = new File("resources/hotkeys.ini");

I also tried

InputStream in = getClass().getClassLoader().getResourceAsStream("/resources/hotkeys.ini");

but it gave me null.

How to force Eclipse to export the folder along with jar?

like image 622
ahoj pepiczki Avatar asked May 24 '26 09:05

ahoj pepiczki


1 Answers

When you use "Export" functionality, you need to select all resources that need to be exported (it is visible at the top of the Eclipse export wizard window).

You can find the answer here as well: Java: export to an .jar file in eclipse

like image 197
Michal Borek Avatar answered May 27 '26 00:05

Michal Borek