Can't find class java.lang.NoClassDefFoundError. (Wrong class path?)

Discussion in 'Java' started by qazmlp, Jul 10, 2003.

  1. qazmlp

    qazmlp Guest

    While creating JVM, I am getting the following error:
    Can't find class java.lang.NoClassDefFoundError. (Wrong class path?)

    I gave all the required Jar files in the CLASSPATH. Also, I set the
    LD_LIBRARY_PATH such that, it can pick up libjvm.so available at:
    /usr/java1.2/jre/lib/sparc/libjava.so

    All these did not solve the problem at all.

    How do I proceed ? So far, I spent 15 hours without arriving at any
    solution.
    Could you help?

    Thanks!
     
    qazmlp, Jul 10, 2003
    #1
    1. Advertising

  2. On 10 Jul 2003 08:48:15 -0700, (qazmlp) wrote:

    > While creating JVM, I am getting the following error:
    > Can't find class java.lang.NoClassDefFoundError. (Wrong class path?)


    I assume you mean you are using the Invocation API's to create
    a JVM in your application? Which version for InitArgs are you
    using, 1.1 or 1.2 style? If 1.1, what is the the classpath
    field set to? If you are using 1.2, which property are you
    using to set classpath, -Xbootclasspath? Will need to see the
    args setup and CreateJavaVM() call to really help here.

    > I gave all the required Jar files in the CLASSPATH. Also, I set the
    > LD_LIBRARY_PATH such that, it can pick up libjvm.so available at:
    > /usr/java1.2/jre/lib/sparc/libjava.so


    Based on the error, I guess the classpath is not what it should
    be, inspite of what you say ;-). Let's see the code.

    The LD_LIBRARY_PATH is essential, it won't work properly without
    it. But that's not your problem, the JVM is trying to start so
    you are past this issue (at least temporarily), but it can't find
    some required classes, which means your classpath is bogus somehow.

    > All these did not solve the problem at all.
    >
    > How do I proceed ? So far, I spent 15 hours without arriving at any
    > solution.


    Invocation API problems can be frustrating, the options are
    obscure and tend not to be well documented. Trial and error
    and experience help alot here.

    --Joe
     
    Joseph Millar, Jul 10, 2003
    #2
    1. Advertising

  3. On Thu, 10 Jul 2003 15:56:12 GMT, dhek bhun kho
    <> wrote:

    > You shouldn't be setting the LD_LIBRARY_PATH. The default settings for the
    > LD_LIBRARY_PATH should be correct. It's strange that your VM doesn't pick
    > up the rt.jar; on my machine the Sun VM always prepends rt.jar. Or have
    > you have been tweaking the boot classpath settings?


    I suspect he is trying to start the JVM using the JNI Invocation
    API's inside of another app/program. That means he can't rely
    on the standard java launcher which handles these details for
    you. Or I could be way off base.

    --Joe
     
    Joseph Millar, Jul 10, 2003
    #3
  4. Joseph Millar <>, Thu, 10 Jul 2003 18:43:58
    +0000:

    > On Thu, 10 Jul 2003 15:56:12 GMT, dhek bhun kho
    > <> wrote:
    >> You shouldn't be setting the LD_LIBRARY_PATH. The default settings for the
    >> LD_LIBRARY_PATH should be correct. It's strange that your VM doesn't pick
    >> up the rt.jar; on my machine the Sun VM always prepends rt.jar. Or have
    >> you have been tweaking the boot classpath settings?

    > I suspect he is trying to start the JVM using the JNI Invocation
    > API's inside of another app/program. That means he can't rely
    > on the standard java launcher which handles these details for
    > you. Or I could be way off base.


    No you're right. My mistake, I misread it. I haven't had this problem, as
    I haven't done extensive coding launching a JVM from C.

    Somebody else?
     
    dhek bhun kho, Jul 10, 2003
    #4
  5. qazmlp

    Roedy Green Guest

    Roedy Green, Jul 11, 2003
    #5
  6. Roedy Green <>, Fri, 11 Jul 2003 17:05:03 +0000:

    > On 10 Jul 2003 08:48:15 -0700, (qazmlp)
    > wrote or quoted :
    >
    >>NoClassDefFoundError

    >
    > this is my most dreaded error. It can have a multitude of causes.
    > see http://mindprod.com/jgloss/errormessages.html#NOCLASSDEFFOUNDERROR


    You misread the post.

    he says:
    >>While creating JVM, I am getting the following error:
    >>Can't find class java.lang.NoClassDefFoundError. (Wrong class path?)


    The original poster is writing that he is creating the JVM through a JNI
    call in C.

    http://www.inonit.com/cygwin/jni/invocationApi/launch.html
    http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/invocation.html#wp15956
    http://java.sun.com/j2se/1.4.2/docs/guide/jni/jni-12.html#JNI_CreateJavaVM

    I would be tempted to add the rt.jar to JavaVMOption*, but that seems an
    ugly hack. Maybe it isn't, it's C after all; so it could be the only way
    to do it. I was perusing the documentation to find out whether there is a
    boot class path hardcoded into the Invocation API. But on the other hand
    that doesn't seem likely.

    Greets
    Bhun.
     
    dhek bhun kho, Jul 11, 2003
    #6
  7. On Fri, 11 Jul 2003 20:43:55 GMT, dhek bhun kho
    <> wrote:

    > I would be tempted to add the rt.jar to JavaVMOption*, but that seems an
    > ugly hack. Maybe it isn't, it's C after all; so it could be the only way
    > to do it. I was perusing the documentation to find out whether there is a
    > boot class path hardcoded into the Invocation API. But on the other hand
    > that doesn't seem likely.


    Strictly speaking, it's not really necessary to tell the JVM where
    to find its own jar files, you usually do that by simply asking
    the API to fill in the default startup values, which you can then
    go tweak, add to, delete from, etc. Depending on your needs and
    your environment, it's sometimes easier to just make the values up
    yourself, as long as you know what you need.

    JNI_GetDefaultJavaVMInitArgs(void *args) is the API that fills in
    the required info. It's good to call when you're just learning
    so you can see what it comes back with. You will find that most
    of the information it finds ends up in the system properties in
    one form or other.

    --Joe
     
    Joseph Millar, Jul 11, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page