Home > Java > Javagetting Started > body text

How to run java program

angryTom
Release: 2019-11-09 17:05:52
Original
9816 people have browsed it

How to run java program

How to run java program

1. First we need a java program, a simple Hello Java as an example:

public class HelloJava{
    public static void main(String[] args){
        System.out.println("Hello Java");
    }
}
Copy after login

After saving the above code as a .txt document, change the suffix name to .java (recommended study: java course)

Get the file as shown in the figure: it doesn’t matter if the icons are different, the suffixes are the same.

How to run java program

#2. Next, we hold down the shift right key in the directory of the file at the same level and open the command line

3. We use the javac command to generate a .class file that can be executed on the command line, as shown in the figure:

How to run java program

(Ps: Pay attention to the suffix when entering Bring your name with you)

After execution, the display is as follows:

How to run java program

You can see that a .class file with the same name has been generated on our desktop:

How to run java program

#4. So how do we execute it? Use the java command:

How to run java program

#You can see the output "Hello Java" required in our code.

The above is the detailed content of How to run java program. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!