Headfirst program doesn't run in cmd

Started by
1 comment, last by !Null 11 years, 8 months ago
I am following along with HeadFirst java. Got the path(s) correct, checked to make sure java was installed correctly with javac. I created a folder in: C:\Users\JEFFD\headfirst. Changed dir to C:\Users\JEFFD\headfirst. When I try and run javac MyVeryFirstApp.java, the dos window pauses for a half a second and returns with C:\Users\JEFFD\headfirst.



public class MyVeryFirstApp {

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


thanks for any help.
Advertisement
That is to be expected. Javac is just the compiler that generates bytecode from your program. You can execute the program using the java command.
Darookie is right, once the compiler has created the jar, if you run a command line from the same folder as the .jar you can use the cmd

java -jar MyVeryFirstApp.jar

that will run the jar from the cmd....or you could just double click it.
/********************************************************************************\
/**********************He Who Dares, Wins**********************************\
/********************************************************************************\

This topic is closed to new replies.

Advertisement