I want to make a jar file which finds similarities between task labels. For this reason I use 2 java libraries of WordNet dictionary: JWNL-1.4-rc3
and JWI-2.3.3
. I also have placed, in the resources
folder of myProject
, the properties.xml
file that is needed by JWNL library in order to be initialized, as well as the WordNet dictionary:
src/main/resources/
properties.xml
WordNet-3.0/dict (dict has 24 files inside)
The properties.xml
file has the dictionary path with the value:
<param name="dictionary_path" value="WordNet-3.0\dict"/>
In my code, I have the two code snippets shown below.
This code initializes the JWNL library:
try {
JWNL.initialize(similarities.class.getClassLoader().getResourceAsStream("/properties.xml"));
}
catch (JWNLException e) {
e.printStackTrace();
}
similarities
is my main class.
This is the constructor of the JWI dictionary:
try {
//String path = similarities.class.getProtectionDomain().getCodeSource().getLocation().getPath();
dict=new Dictionary(this.getClass().getClassLoader().getResource("WordNet-3.0\\dict"));
dict.open();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But when I export an executable jar and run it in the console, I get the following error:
net.didion.jwnl.JWNLException: Properties file invalid or not found
at net.didion.jwnl.JWNL.initialize(JWNL.java:103)
at com.iteforth.annotationToBPM.similarities.main(similarities.java:576)
Exception in thread "main" java.lang.NullPointerException
at edu.mit.jwi.data.FileProvider.<init>(FileProvider.java:191)
at edu.mit.jwi.data.FileProvider.<init>(FileProvider.java:166)
at edu.mit.jwi.data.FileProvider.<init>(FileProvider.java:148)
at edu.mit.jwi.Dictionary.<init>(Dictionary.java:41)
at com.iteforth.annotationToBPM.similarities.<init>(similarities.java:92)
at com.iteforth.annotationToBPM.similarities.main(similarities.java:627)
I have already opened my jar file and I have checked that there is a resources
folder inside with the properties.xml
and the WordNet dictionary. I also have opened MANIFEST
and I have seen that the class path is: .
(full stop)
I have read many threads about this issue for 3 days but nothing has solved my problem. I will appreciate any help.
Tell me if I must send something else, e.g., the POM.xml
or properties.xml
files.