Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help! java.lang.No Class Def ErrorFound: cool

 
M. Whatke
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
I'm kind of new to java and need help compiling code. Basically, I can't do it. You see I wrote this code and It won't compile. Here it is:

class cool {
public static void main (String[] args) {
System.out.println("I am so cool");
System.out.println("I am cool");
System.out.println("I Rule!");
}
}
Whats going on?
M. Whatke
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch Michael. It won't compile or it won't run? NoClassDefFoundError is thrown by a ClassLoader at runtime when there is a reference to a class that is not in the CLASSPATH. Give us some specifics like what operating system you are using, what version of Java you are using and so forth and maybe we can get you started on your Java programming career.
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Judging from the statements, I'd say that you didn't first compile the class. Run "javac cool.java" first to compile the code (which will produce a "cool.class" file), then run "java cool" (note that you do not specify the .class extension)
BTW, welcome to JavaRanch! One small point of order: while your sample code is readable enough as is, sometimes posting larger or more involved segments of code can be tough to read. I'd just like to point out the "CODE" button on the message edit screen. Simply push the button and place your code between the tags that appear in the message box. (Or, you can hand-code the [ CODE] and [ /CODE] tags yourself; I find it faster to type than use the mouse...)
[ July 24, 2003: Message edited by: Joel McNary ]
 
M. Whatke
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I figured out that the dos prompt did not reconize my command "javac" because I had not Installed the Java SDK properly and there for I was not in the right directery to use the "javac"..."

Thanks again,
M. Whatke
P.S.
boolean youarecool = true;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic