how-to

Java runtime & enviroment

How to make simple java program with command-line tools

In this example is showned how to make simplest java program with command-line java tools. There are three steps.

STEP 1: Create program file

Java program has .java extension. Name the file First.java and create inner class First with main() method:

/* This is a first java program. */

public class First {

  public static void main( String[] args )
  {
    System.out.println( "This is a first java program" );
  }

}

STEP 2: Compile First.java with java compiler

From command-line (and from created file directory) run javac.exe for program compilation. If is all OK, in the directory will be created new compiled file First.class.

STEP 3: Run compiled file

Call java.exe with compiled file as parameter for program running.