Build a project manually (console, DOS, Jar)

Source: Internet
Author: User

In simple terms, the construction project is to compile, package, run, deploy, and perform other operations.

(1) preparation: Create a helloworld folder to store the project. There are two folders SRC and build in the root directory of the helloworld project, and SRC is the source code folder, build is used to place the files obtained after the project is built. The build folder contains the classes and Lib folders, And the classes is used to place the class files obtained by compiling java files in SRC, lib is used to place the jar packages generated or referenced by the build project.

(2) The code for creating helloworld. Java in helloworld is as follows:

Public class helloworld {
Public static void main (string [] ARGs ){
System. Out. println ("Hello world! ");
}
}

Compile the Java class in the doscommand line as follows:

First, switch the path to the project directory, and then call javac to compile the source file.

-Sourcepath SRC: Specifies the Java file to be compiled in the SRC folder;

-D Indicates placing the generated class file in the build \ Classes directory.

(3) generate jar:

When you package and generate a jar file, you need to provide the mainifest file. In this file, you can configure main-class, that is, class containing the main method, as the program portal for calling and executing this jar package, you can configure the information of other referenced class libraries and packages in this file.

Run the echo main-class: helloworld> manifest command to generate a manifest file and specify main-class o helloworld.

(4) run the project:

1. Execute the compiled Java class directly.

The CP parameter specifies the path of the helloworld class file.

2. Execute the JAR file in the doscommand 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.