I'm trying to use JAWS Api for Wordnet, and i want to do a test with this code :
import edu.smu.tspell.wordnet.*;
public class Wordnettest {
public static void main(String[] args) {
System.setProperty("wordnet.database.dir", "/var/www/toto/Wordnet/WordNet-3.0/dict/");
WordNetDatabase database = WordNetDatabase.getFileInstance();
NounSynset nounSynset;
Synset[] synsets = database.getSynsets("bus", SynsetType.NOUN);
System.out.println("Le Mot Bus");
for (int i = 0; i < synsets.length; i++) {
nounSynset = (NounSynset) synsets[i];
System.out.println("Définition " + i + " : "
+ nounSynset.getDefinition());
System.out.println("Synonymes du Mot : ");
for (String syn : nounSynset.getWordForms())
System.out.println(" " + syn);
}
}
But when i compile, using : javac -cp jaws.jar Wordnettest.java My Wordnettest.class is here, but when i launch it with : java Wordnettest I have this :
Exception in thread "main" java.lang.NoClassDefFoundError: edu/smu/tspell/wordnet/WordNetDatabase
at Wordnettest.main(Wordnettest.java:11)
Caused by: java.lang.ClassNotFoundException: edu.smu.tspell.wordnet.WordNetDatabase
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
... 1 more
I don't understand why because i set the dic with setProperty...
Could you help me ? Thanks!
You have to add that jar into classPath for the project as well as the server if you are using one.
To do so:
All the answers I read when I had the issue failed to mention the Run Configuration for the server.