I am using a Jasper library to make calls to a prolog file. This is how the call is done:
sics = new SICStus();
sics.load( "/a/string/with/path/to/source.pl" );
What i am trying to do is generate a jar executable that contains the source file. The problem is that i can't find a way to get the path to the resource contained within the jar. So far i am able to get the URL to the jar:
URL url = getClass().getResource( file_name );
String path = url.getPath();
The question is how do i give the object "sics" the path to the source file source.pl within the jar?
What made me understand the problem :
Files in java can only represent direct filesystem files, not the ones in zip/jar archives. To fix it: Try to use
getClass().getResourceAsStream()
and use that instead ofFile
.
Link: URI is not hierarchical exception when running application from JAR