Executing a Java program with a package name at the command line

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.