Compilers, JAVA, Programmimg Languages

How to run Java program from CMD

Let’s say your file is in C:\mywork\

Run Command Prompt

C:> cd \mywork

This makes C:\mywork the current directory.

C:\mywork> javac

This runs javac.exe, the compiler. You should see nothing but the next system prompt…

C:\mywork> dir

javac has created the filenamehere.class file. You should see and filenamehere.class among the files.

C:\mywork> java filenamehere

This runs the Java interpreter. You should then see your program output.

If the system cannot find javac, check the set path command. If javac runs but you get errors, check your Java text. If the program compiles but you get an exception, check the spelling and capitalization in the file name and the class name and the java HelloWorld command. Java is case-sensitive!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s