PDA

View Full Version : Can't run simplest Java app!


ThunderPoit
2006-11-05, 23:48
So I decided i wanted to tech myself some OOP and i picked up a book on java (head first series).

First thing i try to compile is a very simple "Hello world" type app (code below).
It compiles without error, however, i get an exception thrown at me when i try to execute it.

Source code for class:

public class MyFirstApp {
public static void main (String[] args) {
System.out.print("I Rule!");
System.out.print("The World!");
}
}


error message displayed upon execution:


Exception in thread "main" java.lang.NoClassDefFoundError: MyFirstApp/class


i know my java is up to date, but i still can't figure out what is wrong. Any suggestions?


EDIT:
*smacks forhead onto desk*
had i read the book a little more carefully, i would have seen that i need to type "java MyFirstApp" to execute it, not "java MyFirstApp.class"

sorry for the disruption folks :o

Brad
2006-11-05, 23:51
How are you trying to execute it?

It looks like you're doing this:
java MyFirstApp.class

You should be doing this:
java MyFirstApp

ThunderPoit
2006-11-05, 23:51
doh! brad beat me to my edit!

Brad
2006-11-05, 23:52
Glad to be of service. ;)