java.lang.NoClassDefFoundError

Y

yawnmoth

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");
}
}
 
B

Benji

yawnmoth said:
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 ".".
 
I

IchBin

yawnmoth said:
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(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-)
 
I

IchBin

IchBin said:
yawnmoth said:
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(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)

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

yawnmoth

IchBin said:
IchBin said:
yawnmoth said:
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.
 
R

Roedy Green

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.
 
P

Pszemus

yawnmoth said:
IchBin said:
IchBin said:
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). :)
 
Joined
Nov 22, 2008
Messages
1
Reaction score
0
probably just...

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
 
Joined
May 23, 2012
Messages
1
Reaction score
0
جماعه بليز عندي مشكله لما بعمل 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(SecureClassLoader.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.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:472)
Exception in thread "main" Java Result: 1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top