Sign in to follow this  
Jeffige

Headfirst program doesn't run in cmd

Recommended Posts

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.


[CODE]
public class MyVeryFirstApp {

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

thanks for any help.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this