Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

NoClassdefFoundError

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Glen Scheel
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That was it. Thanks a ton!
Glen
 
reply
    Bookmark Topic Watch Topic
  • New Topic