I have a jar and resource files are in the jar root directory. Inside the code I have:
Kernel.class.getResourceAsStream(resource);
I start the application as
java -cp myjar.jar com.mycompany.MyClass
However, the resource is not found.
I have a jar and resource files are in the jar root directory. Inside the code I have:
Kernel.class.getResourceAsStream(resource);
I start the application as
java -cp myjar.jar com.mycompany.MyClass
However, the resource is not found.
You need your current directory in your classpath.
Linux:
java -cp myjar.jar:. com.mycompany.MyClass
Windows:
java -cp myjar.jar;. com.mycompany.MyClass
I needed to precede the resource name by slash "/". Then finding the resource in the jar root directory works fine