Home  >  Article  >  Java  >  Java Example - How to execute compiled Java files

Java Example - How to execute compiled Java files

黄舟
黄舟Original
2017-02-21 09:45:441324browse

In this article we demonstrate how to execute the compiled 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 the javac command to compile the Java file. After executing the command, it will be in the current directory A HelloWorld.class file will be generated. We can 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

The above is the Java example - how to perform compilation Through the contents of the Java file, please pay attention to the PHP Chinese website (www.php.cn) for more related content!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn