-1

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 of File.

Link: URI is not hierarchical exception when running application from JAR

Community
  • 1
  • 1

1 Answers1

2

Guess this question is already answered if I do not misunderstand you request. Please take a look here: How to get the path of a running JAR file? or here How to get a path to a resource in a Java JAR file and here Loading a file relative to the executing jar file.

Community
  • 1
  • 1
ulyumzax
  • 21
  • 2
  • Yes, i have seen all those posts, have tried all the options they gave. It might be my fault, but i find those answers either trying to go around the problem or simply not clear enough. – Ricardo Agra May 19 '16 at 15:17