Friday, 9 December 2016

Running a Java Program with Command Prompt

Hi guys, this post is specially for the newbie JAVA programmer, originally when i had written my first JAVA program after i had installed the JVM(Java Virtual Machine) of course, i was not using any development environments then, so i had to run the program through Command Prompt.I decided to share how i did this

  • open the directory where the file is stored, make sure to store the program as .java if you used notepad to write it.
  • when you have located the directory it is stored in you simply have to compile the .java file and to do this you simply type "javac   test.java" and this should automatically create a class file for you if there are no errors in the code.
  • Finally you run the java class file using the "java  test", make sure the name of the class is the same as the name of the file, example 
public class Test{


}

File name when saved - Test.java.

Thats everything basically.


Become a web developer

No comments:

Post a Comment