Commands to import third-party jar packages to run Java programs using the Java command-line method

Source: Internet
Author: User

1. First use the command line to enter the folder where A.java is located: (for example, my D:\javaeeworkspace\SharedPS_WS\src\com\dyf\main in a path like this)

D: Enter,

CD D:\javaeeworkspace\SharedPS_WS\src\com\dyf\main Enter,

2. Run the A.java source file using the Javac command, use the –classpath parameter to specify the path to the jar package when the runtime needs to use a third-party jar package:

For example, the jar package for my CXF framework is under the C:\D\Java\cxf\apache-cxf-3.1.14\lib path, and when you run the Javac command, use the

Javac-classpath ".; c:\d\java\cxf\apache-cxf-3.1.14\lib\* "Server.java Enter,

3. However, after you run the class file, you need to return to the path outside the package where the class file is located, and use Java–classpath to run the class file (the class file needs to enter the package name).

If the above is not clear, please see the real case below.

As below, attach my real case:

I have used eclipse to run the Java file correctly, generated the class file, and used the command line to enter the previous path to the package where the class file is located, such as:

The path of the class file:

The path of the third-party jar package:

When I run, I use the following command:

1. Use the command line to enter the D drive:

D: Enter

2. Under the previous path of the package that contains the Java file where the main function resides:

CD D:\javaeeworkspace\SharedPS_WS\build\classes

3. Using the Java command, Java-classpath ".; c:\d\java\cxf\apache-cxf-3.1.14\lib\* "Com.dyf.main.Server Enter

Note: Classpath in the.; Not less.

As the level of the editor is limited, if there are any irregularities or questions in the article, you may be grateful to comment directly below.

Commands to import third-party jar packages to run Java programs using the Java command-line method

Related Article

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.