From a java application i made, I build the corresponding jar file.
I copy all the resources in the jar file.
For example, if in src/main/resources
there exists the following resource /folder/my-file
, then it's copied in the jar with the same path.
But if i execute the jar, the loading of the resources fails.
Specifically, it throws an IOException like this
java.io.IOException: Unable to resolve
"file:/my-jar.jar!/folder/my-file" as either class path, filename or
URL
How should I load the resources?
If I run the java app in eclipse, all works fine, even the resources are loaded correctly.
EDIT:
I'm getting the path of the resource via:
MyClass.class.getResource("/folder/my-file").getPath();
The loading of the resource is made by an external library, what i have to d is just specify the path.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…