Take the E-disk for example, into the DOS environment, switch to the e-disk, create MyProject, under which the source and Classes folder, source code, classes put the compiled class file. To switch to source, create a Demo.java, and proceed as follows:
Create Folder command for MD or mkdir, create File command with Cd.>demo.java create empty file or echo Tt>demo.java to create file with tt+ carriage return, echo rr>> The Demo.java representative appends rr+ carriage return after the contents of the demo file. The operation is as follows:
Edit the Demo.java entry procedure as follows:
Under current directory, compile the. java file, dos command for javac-d. /classes Demo.java, as follows:
In the Classes folder to generate the Demo.class file, switch to the classes directory, execute the DOS command Java Demo, as follows:
In the current directory to create the Manifest.txt file, the DOS command is echo main-class:demo>manifest.txt, note: dos command main-class: There is a space between the Demo. The commands and contents are as follows:
Manifest tells the Java Virtual machine which class contains the main method, the class file and the manifest file into a jar package, the DOS command is JAR-CVMF manifest.txt T.jar Demo.class, generate T.jar in the current directory, execute as follows:
Enter the DOS command in the current directory Java-jar T.jar perform the following:
Enter Move T.jar. /, move T.jar to the MyProject folder. As follows:
Switch to MyProject and enter the DOS command JAR-TF T.jar to see a list of hierarchies and files under the jar package. As follows:
Enter the DOS command JAR-XF T.jar to extract the jar package to the current directory, as follows:
To prevent the name of the class, we wrap the class into the package, such as the full name of the class Com.blog.java.Demo, switch to the source directory, create a Com->blog->java three folders, and copy Demo.java to the Java folder. As follows:
The DOS copy command is copy: \.. \demo.java java, path \, edit Demo.java in Java directory, add "package com.blog.java;" In the first line, as follows:
Switch to the source directory, enter the compile command javac-d: /classes Com/blog/java/demo.java or javac-d. /classes com/blog/java/*.java,* represents all of the Java files under it, as follows:
COM folders are generated under the classes directory, and the hierarchy is the same as COM under source, and the generated Demo.class is under Classes/com/blog/java. As follows:
Switch to the Classes directory and enter the Execute command Java Com.blog.java.Demo, as follows:
Modify the Manifest.txt content for the Main-class:com.blog.java.demo,dos command for Echo Main-class:com.blog.java.demo>manifest.txt, as follows:
To make the COM folder and the manifest file into a jar package, enter JAR-CVMF manifest.txt d.jar com in the current directory as follows:
Move D.jar to MyProject, switch to MyProject, execute java-jar d.jar output Hello world, enter JAR-TF D.jar show file list under Jar package, enter JAR-XF D.jar Extract the jar package to the current directory. As follows:
DOS Command project creation, compilation, execution, and jar package generation