The question of how to run a Java file with a package name on the command line has not been understood until today, and it finally dawned on me.
Here is my program code
PackageBonn.thread;ImportJava.sql.SQLOutput;/*** Created by Lin-953 on 2016/1/15.*/ Public classTestthread { Public Static voidMain (string[] args) {Runner R=NewRunner (); Thread T=NewThread (R); T.start (); for(intj = 0; J < 100; J + +) {System.out.println ("main==" +j); } }}classRunnerextendsThread/*implements Runnable E*/ { Public voidrun () { for(inti = 0; I < 100; i++) {System.out.println ("Thread runner=======" +i); } }}
My files are saved in the D:\share directory.
At the command line, follow these input commands
D:\share>javac-d. Testthread.java//The purpose of this command is to generate a folder according to the package name of the file and put the compiled class file in the generated folder, notice that there is a point in the middle of the command,
There are spaces around the point, this cannot be missed.
D:\share>java Bonn.thread.TestThread
Finally, the result of the program running.
Executing a Java program with a package name at the command line