File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes NoClassdefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "NoClassdefFoundError" Watch "NoClassdefFoundError" New topic
Author

NoClassdefFoundError

Glen Scheel
Greenhorn

Joined: Nov 19, 2003
Posts: 7
Hello All,
I am just starting to learn Java. I am trying to learn on my own using the book "Java Programming Fundamentals" by Kimberly Seefeld. I like the book so far but I have run into a problem. I have typed up the following example program from the book:
// A simple program solving an equation with a variable.
public class solveForX2 {
public static void main (String args[])
{
int x=0;//variable is initialized
System.out.println("If x+3=8, what is x?");
x=8-3; //an equation to solve for x
System.out.println("x = " + x);
}
}
I save it as solveForX2.java and javac compiles it into solveForX2.class, but when I try to run it I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: solveForX2/class
I have checked it over multiple times and I cannot find any typos or mistakes on my part.
Can anyone tell me why this won't run?
Thanks,
Glen
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8262

Sounds like you are trying to run it with the command:
java solveForX2.class
The correct command is:
java solveForX2
".class" is the file extension for a class file. It is not part of the name of the class. If I had a dime for every time I've typed java something.java and received the same error.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Glen Scheel
Greenhorn

Joined: Nov 19, 2003
Posts: 7
That was it. Thanks a ton!
Glen
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: NoClassdefFoundError
 
Similar Threads
Infinite while loop
stars
bitwise operations
Iteration using Newton Raphson's method
ternary operators