1

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!

Tomas Bisciak
  • 2,801
  • 5
  • 33
  • 57
Pusheen_the_dev
  • 2,077
  • 4
  • 17
  • 33
  • This is my answer to similiar question which will help you http://stackoverflow.com/questions/24057041/unable-to-load-java-class-from-w3c/24057478#24057478 You need to add that class into classPath.I guess Wordnet is some external library?If you have jar simply add it corrctly to class path.Easy way is to let IDE do it for you. – Tomas Bisciak Sep 05 '14 at 00:53
  • Thanks for answer! The problem is, Wordnet/Dict is not a jar.. It's a database I don't really understand their doc.. http://lyle.smu.edu/~tspell/jaws/index.html I precise, i'm on Ubuntu.. There is no explanation for linux :/ – Pusheen_the_dev Sep 05 '14 at 00:56
  • Im not sure if im looking at a corect lib http://lyle.smu.edu/~tspell/jaws/ bottom of the page shows code that you have here, you can downlaod docs/src/bin .. also jar file.What ide are you using?Exception that you posted here is showing that you have problem with class, its not in classPath .. there isnt any other problem visible here. – Tomas Bisciak Sep 05 '14 at 01:03
  • Yeah, i use their demo code for testing the compilation.. I have already the jar files, but, i'm trying to execute with : java -classpath jaws.jar -Dwordnet.database.dir=WordNet-3.0/dict/ Wordnettest And it didn't work too.. – Pusheen_the_dev Sep 05 '14 at 01:07
  • Maybe problem with paths(incorrect locations)?-I doubt that command differs on linux/windows.Bud i have no experience with linux.If i woud be you, i woud just download theyr lib/take source code,recompile in ide.Less error prone. – Tomas Bisciak Sep 05 '14 at 01:15

1 Answers1

0

You have to add that jar into classPath for the project as well as the server if you are using one.

To do so:

Right click on project -> Build path -> Configure Build Path -> Add External JARs -> Select JAWS-version.jar

Run -> Run Configurations -> Select Your server -> Class path tab -> Click on user Entries -> Add External JARs -> Select JAWS-version.jar

All the answers I read when I had the issue failed to mention the Run Configuration for the server.

Community
  • 1
  • 1