I have a jar file with bundled resources (language model binary files) that need loading at run time. The directory structure within the jar is
tagger/app.class
tagger/models/stop/SentDetect.bin.gz
where SentDetect.bin.gz is a binary whos path is loaded into a thirdparty class (SentDetector) as a String parameter, i.e.
URL url = this.getClass().getResource("models/stop/SentDetect.bin.gz");
SentenceDetector sdetector = new SentenceDetector(url.getPath());
While it runs ok in Netbeans, when I try to run it as a jar from command line, I get a FileNotFound Exception at the constructor. I have double checked that the binary is included in the compiled Jar file.
I believe the solution would usually be to load the data in as an input stream using getResourceAsStream(), but this is not an option here, as the url is being passed as a String parameter to a third party constructor, which leads me to believe the problem is with how the url is being parsed to a String?
I have tried:
url.getPath();
url.getFile();
url.toURI().getPath();
url.toString();
and all are giving different paths to the file.