package run time error: NoClassDefFoundError

Discussion in 'Java' started by Matt, Jun 8, 2004.

  1. Matt

    Matt Guest

    This program yields the following run time error. Any ideas??

    package proj1;
    import java.io.*;

    public class PackageTest
    {
    public static void main(String[] args)
    { System.out.println("Package Test");
    }
    }

    Exception in thread "main" java.lang.NoClassDefFoundError: PackageTest (wrong name:
    proj1/PackageTest)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(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)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Matt, Jun 8, 2004
    #1
    1. Advertising

  2. "Matt" <> schrieb im Newsbeitrag
    news:...
    > This program yields the following run time error. Any ideas??
    >
    > package proj1;
    > import java.io.*;
    >
    > public class PackageTest
    > {
    > public static void main(String[] args)
    > { System.out.println("Package Test");
    > }
    > }
    >
    > Exception in thread "main" java.lang.NoClassDefFoundError: PackageTest

    (wrong name:
    > proj1/PackageTest)
    > at java.lang.ClassLoader.defineClass0(Native Method)
    > at java.lang.ClassLoader.defineClass(Unknown Source)
    > at java.security.SecureClassLoader.defineClass(Unknown Source)
    > at java.net.URLClassLoader.defineClass(Unknown Source)
    > at java.net.URLClassLoader.access$100(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)
    > at java.lang.ClassLoader.loadClassInternal(Unknown Source)


    I guess you called
    java proj/PackageTest

    You have to call
    java proj.PackageTest

    Sebastian
    Sebastian Scheid, Jun 8, 2004
    #2
    1. Advertising

  3. Matt

    kaeli Guest

    In article <>,
    enlightened us with...
    > This program yields the following run time error. Any ideas??


    I get that every time I accidentally type
    java myClass.java
    instead of
    javac myClass.java
    or
    java myClass

    You might also have named your file different than the class or not have
    it in the right directory.
    The class is PackageTest in package proj1, then the file must be in
    /home/myDir/proj1/PackageTest.java
    and classpath must have
    /home/myDir/
    in it.
    (obviously, put your directory in place of /home/myDir/)
    The package directory has to match the package name and the file name
    has to match the class name.

    --
    --
    ~kaeli~
    Synonym: the word you use in place of a word you can't
    spell.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
    kaeli, Jun 8, 2004
    #3
    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.
Similar Threads
  1. NathanK
    Replies:
    4
    Views:
    887
    Andrew Thompson
    Mar 2, 2004
  2. Lilian BRUN
    Replies:
    2
    Views:
    500
    Lilian BRUN
    Mar 5, 2005
  3. Replies:
    1
    Views:
    2,116
    Irmen de Jong
    Jun 22, 2004
  4. flamesrock
    Replies:
    8
    Views:
    434
    Hendrik van Rooyen
    Nov 24, 2006
  5. Pierre Yves
    Replies:
    2
    Views:
    470
    Pierre Yves
    Jan 10, 2008
Loading...

Share This Page