Reputation: 7491
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.
Upvotes: 1
Views: 102
Reputation: 7491
I needed to precede the resource name by slash "/". Then finding the resource in the jar root directory works fine
Upvotes: 0
Reputation: 75356
You need your current directory in your classpath.
Linux:
java -cp myjar.jar:. com.mycompany.MyClass
Windows:
java -cp myjar.jar;. com.mycompany.MyClass
Upvotes: 1