Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
tutorials:java:how_to_create_and_excute_java_jar_file_in_command_line [2019/07/08 11:09]
alanzheng
tutorials:java:how_to_create_and_excute_java_jar_file_in_command_line [2019/07/08 11:11] (current)
alanzheng
Line 8: Line 8:
  
 Save it to CreateAJarFile.java Save it to CreateAJarFile.java
 +
 +==== Compile java file ====
  
 Open a command prompt and navigate to the directory containing your Java program. Then type in the command to compile the source and hit Enter. Open a command prompt and navigate to the directory containing your Java program. Then type in the command to compile the source and hit Enter.
  
 {{:​tutorials:​java:​pasted:​20190708-110334.png}} {{:​tutorials:​java:​pasted:​20190708-110334.png}}
 +
 +==== Create a jar file ====
  
 Now you will create a jar file containing your program. In your command prompt, make sure you're in the same directory as the previous step. Type in the following command and hit Enter. Now you will create a jar file containing your program. In your command prompt, make sure you're in the same directory as the previous step. Type in the following command and hit Enter.
  
 {{:​tutorials:​java:​pasted:​20190708-110437.png}} {{:​tutorials:​java:​pasted:​20190708-110437.png}}
 +
 +==== Excute java class in jar file ====
  
 The benefit of storing your class file in a jar file is that you can execute your class from any location on the file system. To illustrate this important point, navigate to the directory above the one where the class file is stored. The benefit of storing your class file in a jar file is that you can execute your class from any location on the file system. To illustrate this important point, navigate to the directory above the one where the class file is stored.