Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems running code

 
AKIN Ojo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have just started to read the head first java i use a mac os x,
and since the sdk files are supposed to be included with
mac os x, i thought i should discover how to get my java codes
running, and so i haveused the following example in the book

public class abc {

private static void main (String[] args) {
System.out.print("i rule!");
System.out.print("the world!");

}
}

thank you all
[ September 28, 2005: Message edited by: AKIN Ojo ]
 
Phil Dixon
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Akin,

Could you post your code as well.
 
Norm Radder
Ranch Hand
Posts: 882
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's one way to get that message. The file asdf does not exist in the current directory
>java asdf
Exception in thread "main" java.lang.NoClassDefFoundError: asdf

Check where the class file is.

When having runtime errors, please post all the console including what you entered.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15272
37
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> private static void main (String[] args) { ...

The main method should be public, not private.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic