Method to execute java files: (Related video tutorial recommendations: java video tutorial)
Using environment: jdk1.6
File directory:
##javac *.java will generate the corresponding *.class filejava *.class can be executed, .class can be omitted1. There is no package in t.javapublic class t{ public static void main(String[] args) { System.out.println("Hi"); } }The first way The second way 2. a.java is packaged
package test; public class a{ public static void main(String[] args) { System.out.println("Hi"); } }The first way The second method 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!