Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java.lang.NoClassDefFoundError

0 views
Skip to first unread message

yawnmoth

unread,
Nov 27, 2005, 11:06:02 PM11/27/05
to
I'm recieving an Exception in thread "main"
java.lang.NoClassDefFoundError: Test and am not really sure why. I'm
able to compile the file - Test.java - just fine, with javac, however,
when I try to run it, with java, I can't. The contents of Test.java
are as follows:

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

Benji

unread,
Nov 27, 2005, 11:15:17 PM11/27/05
to

How are you trying to run it?

I have a feeling your CLASSPATH is set to something and doesn't include ".".

--
Of making better designs there is no end,
and much refactoring wearies the body.

IchBin

unread,
Nov 27, 2005, 11:33:53 PM11/27/05
to
You have to execute the class with the correct class name... Example
there is a difference between *test* and *Test*

*C:\java test*
Hello world


*C:\java Test*
Exception in thread "main" java.lang.NoClassDefFoundError: Test (wrong
name: test)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

--


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)

IchBin

unread,
Nov 27, 2005, 11:40:01 PM11/27/05
to

Sorry I forgot to mention this. Please, *as a beginner*, post your
questions to c.l.j.help and not this group c.l.j.programmer. An look at
you messages closer. It actually tells you what the problem is.

yawnmoth

unread,
Nov 28, 2005, 12:00:39 AM11/28/05
to

IchBin wrote:
> IchBin wrote:
> > yawnmoth wrote:
> >> I'm recieving an Exception in thread "main"
> >> java.lang.NoClassDefFoundError: Test and am not really sure why. I'm
> >> able to compile the file - Test.java - just fine, with javac, however,
> >> when I try to run it, with java, I can't. The contents of Test.java
> >> are as follows:
> >>
> >> public class Test
> >> {
> >> public static void main(String[] args)
> >> {
> >> System.out.println("Hello world");
> >> }
> >> }
> >>
> > You have to execute the class with the correct class name... Example
> > there is a difference between *test* and *Test*
Wouldn't java Test be correct, in this case, since the name of the
class is Test and not test? In any case, I tried both, and recieved
the same error for each one.

> Sorry I forgot to mention this. Please, *as a beginner*, post your
> questions to c.l.j.help and not this group c.l.j.programmer. An look at
> you messages closer. It actually tells you what the problem is.

I'll keep that in mind next time. Thanks for the tip.

Pszemus

unread,
Nov 28, 2005, 3:37:28 PM11/28/05
to

Maybe it's to obvious, but worth trying for a beginner: Before
executing (java Test), compile (javac Test.java). :-)

--
Pszemus
-==[ GG: 1620292 ]==-
-==[ www: www.sarm.w.pl ]==-
-==[ e-mail: psz...@o2.pl ]==-

Roedy Green

unread,
Nov 28, 2005, 12:17:09 PM11/28/05
to
On 27 Nov 2005 21:00:39 -0800, "yawnmoth" <terr...@yahoo.com> wrote,
quoted or indirectly quoted someone who said :

>Wouldn't java Test be correct, in this case, since the name of the
>class is Test and not test? In any case, I tried both, and recieved
>the same error for each one.

There is no way you would get the SAME error, perhaps a similar error.
In computing, even every comma counts. Please don't paraphrase error
messages.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

0 new messages