Menu

Execute Sphinx4 HelloWorld in terminal(Ubuntu)

2014-04-17
2014-04-17
  • Senjam Shantirani

    I have installed Sphinx4 in ubuntu and executed the HelloWorld demo using Eclipse IDE successfully. I want to execute the same in ubuntu terminal.I tried executing the following in the terminal in the path where my project was created:

    COMPILATION: The command below throws no error and creates 'HelloWorld.class'.
    javac -classpath sphinx4 /home/shanti/Desktop/VOX/src/edu/cmu/sphinx/demo/helloworld/HelloWorld.java

    RUN TIME: The command below throws error, it was used reffering to an instruction from a site.

    java -classpath ../lib/sphinx4.jar ../lib/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar edu.cmu.sphinx.demo.helloworld.HelloWorld

    [I took the path from helloworld.Manifest which lists:

    Main-Class: edu.cmu.sphinx.demo.helloworld.HelloWorld
    Class-Path: ../lib/sphinx4.jar ../lib/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar ]

    ERROR SHOWN BELOW--

    Exception in thread "main" java.lang.NoClassDefFoundError: /home/shanti/Desktop/VOX/src/edu/cmu/sphinx/demo/helloworld/HelloWorld
    Caused by: java.lang.ClassNotFoundException: .home.shanti.Desktop.VOX.src.edu.cmu.sphinx.demo.helloworld.HelloWorld
    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)
    Could not find the main class: /home/shanti/Desktop/VOX/src/edu/cmu/sphinx/demo/helloworld/HelloWorld. Program will exit.

    Please let me know why the errors are happening and how to solve them. Also I am not sure if the command being use to run the application is correct, please advice.I am new to JAVA, ANT and Sphinx4.

    Thanks in advance,
    Senjam Shanti

     
  • Nickolay V. Shmyrev

    Entries in class path are separated by ':', not by space. The command line must be something like this:

      java -cp lib/sphinx4.jar:lib/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar:bin/HelloWorld.jar edu.cmu.sphinx.demo.helloworld.HelloWorld
    

    Since class path is hardcoded in manifest inside the jar, you can also run the following:

       java -jar bin/HelloWorld.jar
    

    Please note that those commands must be run from the top source folder, not from the bin folder.

     
  • Senjam Shantirani

    Hello Nickolay V.Shmyrev,

    Thank you very much for the help.
    It is working fine.

    Thanks,
    Senjam Shantirani

     

Log in to post a comment.