Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > package run time error: NoClassDefFoundError

Reply
Thread Tools

package run time error: NoClassDefFoundError

 
 
Matt
Guest
Posts: n/a
 
      06-08-2004
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(Unknow n 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)
 
Reply With Quote
 
 
 
 
Sebastian Scheid
Guest
Posts: n/a
 
      06-08-2004
"Matt" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed) om...
> 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(Unknow n 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


 
Reply With Quote
 
 
 
 
kaeli
Guest
Posts: n/a
 
      06-08-2004
In article <(E-Mail Removed) >,
http://www.velocityreviews.com/forums/(E-Mail Removed) 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time template list definition / Run-time variable type definition Pierre Yves C++ 2 01-10-2008 02:52 PM
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
single package import v/s the entire package Parvinder Java 6 02-27-2005 02:02 PM
java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory greg.knaddison@gmail.com Python 1 06-22-2004 10:58 PM
Importing a package and looping through modules in the package Dave Python 2 02-10-2004 08:14 PM



Advertisments