Java Example - How to compile Java files


Java 实例 Java Example

In this article we demonstrate how to compile the HelloWorld.java file, where the Java code is as follows:

public class HelloWorld {public static void main(String []args) {   System.out.println("Hello World");}}

Next we use javac command to compile Java files, and use the java command to execute the compiled file:

c:\jdk\demoapp> javac HelloWorld.java
c:\jdk\demoapp> java HelloWorld

The output result of the above code example is:

Hello World

Java 实例 Java example