Today, I tried to create executable jar files. Specifically: first, create a project folder jartest and create a hello package in the jartest directory. Next, follow these steps: 1. Write the hello. Java (your own class name) file under the "hello" directory. The sample content is as follows: Package hello;
Public class Hello {
Public static void main (string ARGs []) {
System. Out. println ("Hello world! ");
}
} 2. compile and generate the hello. Class file. 3. Create a manifest. MF file in the directory at the same level as Hello (the name is unlimited. The sample content is as follows: Main-class: Hello. hello, this file is the most important. The key points are: m (must be capitalized) Ain-C (must be capitalized) lass :( must have a space) package name. class Name (you must press Enter) 4. Run the command jar cvfm. jar manifest. mf Hello/generate. jar5. Test and run Java-jar. jar6. output result: Hello world! The complete operation process is as follows: ========================================================== ============ D: \ Program Files \ Java \ SRC \ jartest \ Hello> javac hello. javad: \ Program Files \ Java \ SRC \ jartest \ Hello> Cd .. d: \ Program Files \ Java \ SRC \ jartest> jar cvfm. jar manifest. mf Hello/
Manifest)
Added: Hello/(read = 0) (write = 0) (stored 0%)
Added: Hello/Hello. Class (read = 422) (write = 289) (compressed by 31%)
Added: Hello/Hello. Java (read = 136) (write = 108) (compressed by 20%) D: \ Program Files \ Java \ SRC \ jartest> JAVA-jar A. Jar
Hello world! D: \ Program Files \ Java \ SRC \ jartest >=========================== =============================== after compilation, you can set hello. java deletion.
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.