Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

java.lang.NoClassDefFoundError

Thread view: 
yawnmoth - 28 Nov 2005 04:06 GMT
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 - 28 Nov 2005 04:15 GMT
> 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
> {
[quoted text clipped - 3 lines]
>     }
> }

How are you trying to run it?

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

Signature

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

IchBin - 28 Nov 2005 04:33 GMT
> I'm recieving an Exception in thread "main"
> java.lang.NoClassDefFoundError: Test and am not really sure why.  I'm
[quoted text clipped - 9 lines]
>     }
> }

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)

Signature

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 - 28 Nov 2005 04:40 GMT
>> I'm recieving an Exception in thread "main"
>> java.lang.NoClassDefFoundError: Test and am not really sure why.  I'm
[quoted text clipped - 32 lines]
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

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.

Signature

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-)

yawnmoth - 28 Nov 2005 05:00 GMT
> >> I'm recieving an Exception in thread "main"
> >> java.lang.NoClassDefFoundError: Test and am not really sure why.  I'm
[quoted text clipped - 12 lines]
> > 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.
Roedy Green - 28 Nov 2005 17:17 GMT
>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.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Pszemus - 28 Nov 2005 20:37 GMT
>>>>I'm recieving an Exception in thread "main"
>>>>java.lang.NoClassDefFoundError: Test and am not really sure why.  I'm
[quoted text clipped - 22 lines]
>
> I'll keep that in mind next time.  Thanks for the tip.

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

Signature

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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.