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