Head First Java - probably a really dumb question from the newest newbie ever
zach sycks
Greenhorn
Joined: Dec 18, 2005
Posts: 5
posted
0
I just worked through this first example in the book and I can't figure out why it issues an error when I try to run it.
public class MyFirstApp {
public static void main (String[] args) { System.out.println("I Rule!"); System.out.println("The World"); }
}
I saved it as MyFirstApp.java. I compiled it (javac MyFirstApp.java) and it generated MyFirstApp.class. I typed at the command line "java MyFirstApp.class" and it says:
I saved it as MyFirstApp.java. I compiled it (javac MyFirstApp.java) and it generated MyFirstApp.class. I typed at the command line "java MyFirstApp.class" and it says:
U have to give "java MyFirstApp" without that .class.
And Hey u can look at this url for more info on running a Java Prog. [ December 18, 2005: Message edited by: Sri Ram ]
Abdulla Mamuwala
Ranch Hand
Joined: Jan 09, 2004
Posts: 225
posted
0
Dear Zach,
Inorder that your program should execute just type the following command, java MyFirstApp You dont need the dot class extension. Have fun [ December 18, 2005: Message edited by: Abdulla Mamuwala ]
zach sycks
Greenhorn
Joined: Dec 18, 2005
Posts: 5
posted
0
just typed that at the command prompt and got the same error. argh.
Abdulla Mamuwala
Ranch Hand
Joined: Jan 09, 2004
Posts: 225
posted
0
Is your class file in the same directory from where you are executing your java command. That is if you have your .class file in say C:\MyPrograms, change directory to that particular directory and than execute your java command i.e, C:\MyPrograms\java MyFirstApp Good Luck