Home > Java > JavaBase > body text

How to execute java (command execution)

Release: 2019-12-06 15:27:50
Original
4277 people have browsed it

How to execute java (command execution)

Method to execute java files: (Related video tutorial recommendations: java video tutorial)

Using environment: jdk1.6

How to execute java (command execution)

File directory:

How to execute java (command execution)

##javac *.java will generate the corresponding *.class file

java *.class can be executed, .class can be omitted

1. There is no package in t.java

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

The first way

How to execute java (command execution)

The second way

How to execute java (command execution)

2. a.java is packaged

package test;
public class a{
    public static void main(String[] args) {
    System.out.println("Hi");
    }
}
Copy after login

The first way

How to execute java (command execution)

The second method

How to execute java (command execution)

Because a.java contains all the class files of the package, when executing the class file, you need to return to the layer where the package is located. Then execute

through the package name.

The above is the detailed content of How to execute java (command execution). 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!