Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 16 of 16

Thread: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    Hello. I am new to java and really need help. I am trying to make a new sphinx app. I keep getting the following message, tried to change the class paths, tried to edit my MANIFEST file. still nothing.

    dekita@dekita-laptop:/usr/local/sphinx4$ java -mx256m -jar bin/RobotTest.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: edu/cmu/sphinx/demo/RobotTest
    Caused by: java.lang.ClassNotFoundException: edu.cmu.sphinx.demo.RobotTest
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: edu.cmu.sphinx.demo.RobotTest. Program will exit


    Any help would be greatly appreciated. Thank you in advance for your help and for the patience you will need!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    edu.cmu.sphinx.demo.RobotTest
    First you need to find the class mentioned in the error message.
    Then you need to put in on the classpath so the java command can find it.
    Can you explain what you have done, where all the files are and show the console when you execute the java command.
    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.

  3. The Following User Says Thank You to Norm For This Useful Post:

    dekitamoon (June 22nd, 2011)

  4. #3
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    Thank you so much for replying ok, now i am dealing with another error message.

    my RobotTest.class was missing in the RobotTest.jar file when i tried executing it by putting:
    dekita@dekita-laptop:/usr/local/sphinx4$ java -mx256m -jar bin/RobotTest.jar

    my RobotTest.jar is within the sphinx4/bin
    within this jar is the MANIFEST and edu/cmu/sphinx/demo/RobotTest which has RobotTest.gram, RobotTest.config.xml, and RobotTest.class
    RobotTest file is also within /usr/local/sphinx/src/apps/edu/cmu/sphinx/demo/

    here is what I did within the terminal, sorry if its more than you need. I have been at this for almost 2 weeks

    -buildMac:

    -components:

    jar:

    check_jsapi_default_present:

    copy_jsapi_jar:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    set_patternset_to_compile:

    set_patternset_to_doc:

    handle_jsapi:

    compile_jsapi2:

    -initVariables:

    -init:

    -dependentComponents:

    -init:

    compileJ2ME:

    preverify:

    compileJSE:
    [echo] compiling javax.speech for JSE with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/javax.speech/build.xml:68: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    jar:

    compileJ2ME:

    preverify:

    compileJSE:
    [echo] compiling org.jvoicexml.jsapi2 for JSE with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/org.jvoicexml.jsapi2/build.xml:115: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    -jar:

    -init:

    compile:
    [echo] compiling with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/org.jvoicexml.jsapi2.jse/build.xml:41: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    jar:

    -buildFreetts:

    -buildSphinx4:

    -init:

    compile:
    [echo] compiling with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/org.jvoicexml.jsapi2.jse.sphinx4/build.xml:48: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    jar:

    -buildSapi:

    -buildMac:

    -components:

    jar:

    jsapi20_jar:

    check_jsapi_default_present:

    copy_jsapi_jar:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    set_patternset_to_compile:

    set_patternset_to_doc:

    handle_jsapi:

    compile_src:

    demos:

    make_lib_dir:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    compile_sphinx_helloworld:

    compile_sphinx_RobotTest:
    [jar] Building jar: /usr/local/sphinx4/bin/RobotTest.jar

    compile_sphinx_hellongram:

    compile_sphinx_lattice:

    compile_sphinx_classbased:

    compile_sphinx_confidence:

    compile_sphinx_raw:

    compile_jsapi_dialog:

    compile_jsapi_jsgf:

    init:

    keystore:

    compile_zipcity:

    compile_sphinx_transcriber:

    compile_aligner:

    compile_tags:

    compile_sphinx_demos:

    all:
    [echo] Build complete.

    BUILD SUCCESSFUL
    Total time: 3 seconds
    dekita@dekita-laptop:/usr/local/sphinx4$ java -mx256m -jar bin/RobotTest.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: edu/cmu/sphinx/demo/RobotTest/RobotTest
    Caused by: java.lang.ClassNotFoundException: edu.cmu.sphinx.demo.RobotTest.RobotTest
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: edu.cmu.sphinx.demo.RobotTest.RobotTest. Program will exit.
    dekita@dekita-laptop:/usr/local/sphinx4$ ant
    Buildfile: /usr/local/sphinx4/build.xml

    all:

    check_jsapi_default_present:

    copy_jsapi_jar:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    set_patternset_to_compile:

    set_patternset_to_doc:

    handle_jsapi:

    compile_src:

    create_all_models:

    check_jsapi_default_present:

    copy_jsapi_jar:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    set_patternset_to_compile:

    set_patternset_to_doc:

    handle_jsapi:

    compile_src:

    create_my_model:

    check_jsapi_default_present:

    copy_jsapi_jar:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    set_patternset_to_compile:

    set_patternset_to_doc:

    handle_jsapi:

    compile_src:

    create_my_model:

    check_jsapi_default_present:

    copy_jsapi_jar:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    set_patternset_to_compile:

    set_patternset_to_doc:

    handle_jsapi:

    compile_src:

    create_my_model:

    check_jsapi_default_present:

    copy_jsapi_jar:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    set_patternset_to_compile:

    set_patternset_to_doc:

    handle_jsapi:

    compile_src:

    jsapi10base_jar:

    sphinx4_jar:

    batch_jar:

    tags_jar:

    audiotool_jar:

    jars:

    check_jsapi_default_present:

    copy_jsapi_jar:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    set_patternset_to_compile:

    set_patternset_to_doc:

    handle_jsapi:

    compile_jsapi2:

    -initVariables:

    -init:

    -dependentComponents:

    -init:

    compileJ2ME:

    preverify:

    compileJSE:
    [echo] compiling javax.speech for JSE with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/javax.speech/build.xml:68: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    jar:

    compileJ2ME:

    preverify:

    compileJSE:
    [echo] compiling org.jvoicexml.jsapi2 for JSE with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/org.jvoicexml.jsapi2/build.xml:115: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    -jar:

    -init:

    compile:
    [echo] compiling with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/org.jvoicexml.jsapi2.jse/build.xml:41: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    jar:

    -buildFreetts:

    -buildSphinx4:

    -init:

    compile:
    [echo] compiling with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/org.jvoicexml.jsapi2.jse.sphinx4/build.xml:48: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    jar:

    -buildSapi:

    -buildMac:

    -components:

    jar:

    check_jsapi_default_present:

    copy_jsapi_jar:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    set_patternset_to_compile:

    set_patternset_to_doc:

    handle_jsapi:

    compile_jsapi2:

    -initVariables:

    -init:

    -dependentComponents:

    -init:

    compileJ2ME:

    preverify:

    compileJSE:
    [echo] compiling javax.speech for JSE with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/javax.speech/build.xml:68: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    jar:

    compileJ2ME:

    preverify:

    compileJSE:
    [echo] compiling org.jvoicexml.jsapi2 for JSE with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/org.jvoicexml.jsapi2/build.xml:115: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    -jar:

    -init:

    compile:
    [echo] compiling with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/org.jvoicexml.jsapi2.jse/build.xml:41: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    jar:

    -buildFreetts:

    -buildSphinx4:

    -init:

    compile:
    [echo] compiling with debug=true, optimize=false
    [javac] /usr/local/sphinx4/src/jsapi2/org.jvoicexml.jsapi2.jse.sphinx4/build.xml:48: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds

    jar:

    -buildSapi:

    -buildMac:

    -components:

    jar:

    jsapi20_jar:

    check_jsapi_default_present:

    copy_jsapi_jar:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    set_patternset_to_compile:

    set_patternset_to_doc:

    handle_jsapi:

    compile_src:

    demos:

    make_lib_dir:

    check_jsapi_jar_present:

    issue_jsapi_warning:

    compile_sphinx_helloworld:

    compile_sphinx_RobotTest:

    compile_sphinx_hellongram:

    compile_sphinx_lattice:

    compile_sphinx_classbased:

    compile_sphinx_confidence:

    compile_sphinx_raw:

    compile_jsapi_dialog:

    compile_jsapi_jsgf:

    init:

    keystore:

    compile_zipcity:

    compile_sphinx_transcriber:

    compile_aligner:

    compile_tags:

    compile_sphinx_demos:

    all:
    [echo] Build complete.

    BUILD SUCCESSFUL
    Total time: 1 second
    dekita@dekita-laptop:/usr/local/sphinx4$ java -mx256m -jar bin/RobotTest.jar
    Exception in thread "main" java.lang.ClassFormatError: Incompatible magic value 791284256 in class file edu/cmu/sphinx/demo/RobotTest/RobotTest
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknow n Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: edu.cmu.sphinx.demo.RobotTest.RobotTest. Program will exit.
    dekita@dekita-laptop:/usr/local/sphinx4$

    within this file is RobotTest.config.xml, RobotTest.gram, RobotTest.java, and RobotTest.Manifest

  5. #4
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    Sorry if I didnt make myself clear in the last message..basically the first error was because I didnt have RobotTest.class within the RobotTest.jar
    now that it does contain this .class file its given me the Incompatible magic value error. *Hittin my head against bathroom mirror*
    Last edited by dekitamoon; June 22nd, 2011 at 12:24 AM.

  6. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    ClassFormatError: Incompatible magic value 791284256
    I think you get that for an invalid class file. Look at the edu/cmu/sphinx/demo/RobotTest/RobotTest.class file with a hex editor and see what the first few bytes of the flle looks like. It should be something like this: CAFEBABE0000003200640A001900

  7. #6
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    i used ghex. Are all editors scared of .jar files? I hopeI did this right but i could not get to the .class file first but i copy and past it to the desktop and and what i got was:


    000000002F 2A 0A 20 A2 20 43 6F 70 79... The Disclaimer Statement....

  8. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    If that is from the .class file, then it definitely is not a .class from the javac compiler.
    It looks like a text file. Open a text editor and the open the file. Or rename it by adding .txt and clicking on it.

    The left hand part of your post shows 000000002F
    that looks to me like the displacement into the file in hex. Ie its not the first bytes of the file.
    It should be 0000000000 to show the first bytes.

  9. #8
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    Why is it a txt file even though I "tried" to compile it in eclipse..which is the only way i know how i thought i knew how to make a jar file etc.

    but I change it to a text file and it showed up. I am not sure what to do from here.

  10. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    Go back to the .java file and try to compile it to create a good .class file. Then build the jar file being sure to use the good .class file.

    Sorry about your IDE being confusing. It is for lots of students (and me also).

  11. #10
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    Is there an easy way to build a jar file? I think thats where i created this flaw. I have just started using linux, ubuntu, sphinx, and eclipse! and none of the sites have a steo by step instruction on using eclipse and builsing a sphinx app. I appreciate your help very much and I will be replying shortly in hopes to say ITS WORKING!

  12. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    I suppose some of the IDEs are useful. I build mine with a batch file and trial and error.
    I have a utility that checks that the contents of the jar file is complete (ie no missing classes) and has no extra class files.

  13. #12
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    Hello. Thank you now that error is gone. I hope im not overstaying my welcome. I have worked it on day and guess what? another error :/
    Here we go..
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:

    at edu.cmu.sphinx.demo.robottest.RobotTest.main(Robot Test.java19)

    I looked at the java file and this is where my main statement is (what tha!..):

    public static void main(String[] args)

  14. #13
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    thats cool @ batch file (trial/error). I wish i knew how to do that cause eclipse is a pain in the hinny

  15. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    Sorry, I have no idea how your IDE works.

  16. The Following User Says Thank You to Norm For This Useful Post:

    dekitamoon (June 22nd, 2011)

  17. #15
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    i have a new error do i have to make a new post?

  18. #16
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NoClassDefFoundError and ClassNotFoundException (sphinx/ant/java)

    thank you sooo much for your help. You were awesome!

Similar Threads

  1. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    By i4ba1 in forum JDBC & Databases
    Replies: 2
    Last Post: August 23rd, 2011, 12:41 PM
  2. java.lang.NoClassDefFoundError
    By nrao in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 27th, 2011, 08:18 AM
  3. java.lang.NoClassDefFoundError
    By anonymous001 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: January 26th, 2011, 04:41 PM
  4. Replies: 3
    Last Post: May 15th, 2010, 02:05 PM
  5. Replies: 1
    Last Post: October 25th, 2009, 11:54 AM