Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > java.lang.NoClassDefFoundError

Reply
Thread Tools

java.lang.NoClassDefFoundError

 
 
yawnmoth
Guest
Posts: n/a
 
      11-28-2005
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");
}
}

 
Reply With Quote
 
 
 
 
Benji
Guest
Posts: n/a
 
      11-28-2005
yawnmoth, while chewing on bamboo shoots, 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");
> }
> }


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.
 
Reply With Quote
 
 
 
 
IchBin
Guest
Posts: n/a
 
      11-28-2005
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*

*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(Secure ClassLoader.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.j ava:18
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:26
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.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-)
 
Reply With Quote
 
IchBin
Guest
Posts: n/a
 
      11-28-2005
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*
>
> *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(Secure ClassLoader.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.j ava:18
> at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:26
> at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
> at java.lang.ClassLoader.loadClassInternal(ClassLoade r.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.

--


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-)
 
Reply With Quote
 
yawnmoth
Guest
Posts: n/a
 
      11-28-2005

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.

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      11-28-2005
On 27 Nov 2005 21:00:39 -0800, "yawnmoth" <(E-Mail Removed)> 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.
 
Reply With Quote
 
Pszemus
Guest
Posts: n/a
 
      11-28-2005
yawnmoth wrote:
> 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.
>


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: http://www.velocityreviews.com/forums/(E-Mail Removed) ]==-
 
Reply With Quote
 
charlitos charlitos is offline
Junior Member
Join Date: Nov 2008
Posts: 1
 
      11-22-2008
ehh you're doing everything fine so far, the only problem i see goes like this:

javac Test.java //fine
java Test.java //wrong

your execution goes WITHOUT the extension

java Test //

hope it helped buddy
 
Reply With Quote
 
Banota Banota is offline
Junior Member
Join Date: May 2012
Posts: 1
 
      05-23-2012
جماعه بليز عندي مشكله لما بعمل run لاي برنامج على ال netbeans
أفيدوني أفادكم الله

java.lang.NoClassDefFoundError: application/Application (wrong name: Application/Application)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :791)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader .java:449)
at java.net.URLClassLoader.access$100(URLClassLoader. java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 361)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:4 23)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:30
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 56)
at sun.launcher.LauncherHelper.checkAndLoadMain(Launc herHelper.java:472)
Exception in thread "main" Java Result: 1
 
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




Advertisments