0

I'm trying to create a plain Main.java file with 2 jar dependencies. I have the program up and running in an Eclipse Java project but when running from command-line as a single java file it can't find a resource path.

The problematic code:

Configuration conf = new Configuration();


conf.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us");
conf.setDictionaryPath("custom.dic");
conf.setLanguageModelPath("custom.lm");

Now the /edu/cmu/sphinx/models/en-us/en-us is part of the sphinx4-data.jar. This path just can't be found when I'm running this as a plain Java file on my Raspberry Pi.

Compile:

javac -cp ".:/home/ivaro18/sphinx4-core.jar:/home/ivaro18/sphinx4-data.jar" Main.java

Run:

java -cp ".:/home/ivaro18/sphinx4-core.jar:/home/ivaro18/sphinx4-data.jar" Main

But the error returned:

Can't locate resouce:/edu/cmu/sphinx/models/en-us/en-us

This worked perfectly in Eclipse Java project, having added these 2 jars to my classpath. But when I'm running this as a plain Java file on my pi, it can't find the resource.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Ivar Reukers
  • 7,560
  • 9
  • 56
  • 99
  • /edu/cmu/sphinx/models/en-us/en-us, is this a directory with respect to your current directory that stores some file? – Optional Oct 05 '17 at 12:18
  • /edu/cmu/sphinx/models/en-us/en-us is a directory in sphinx4-data.jar, but I guess it might also exist on the filesytem if the JAR is processed in Eclipse. The token `resource:` hints that a search will be made on the classpath, or something of that nature, but the documentation doesn't seem to say exactly how. I wonder if it would help to unpack the CMU JARs into the same directory, add the application class(es) and then repack the whole thing to make one big JAR? – Kevin Boone Oct 05 '17 at 12:31
  • Most likely the jars are simply under different path or named differently. – Nikolay Shmyrev Oct 14 '17 at 13:39

0 Answers0