Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| student:java:jar [2024/01/23 10:55] – bernstdh | student:java:jar [2025/10/15 15:08] (current) – bernstdh |
|---|
| ==== Creating an Executable JAR File ==== | ==== Creating an Executable JAR File ==== |
| |
| | You can create an executable JAR file by including a manifest that includes a ''%%Main-Class:%%'' directive. For more information, see the [[ http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html | tutorial ]]. |
| |
| An "executable JAR" file can be executed using the ''%%java%%'' tool with the ''%%-jar%%'' switch or, if the associations are set properly, by "clicking" on it. | The manifest can include a ''Class-Path'' entry that can contain external class files and jar files. FOr more information, see the |
| | [[https://docs.oracle.com/javase/tutorial/deployment/jar/downman.html | tutorial ]]. |
| |
| |
| |
| You can create an executable JAR file by including a manifest that includes a ''%%Main-Class:%%'' directive. For more information, see the [[ http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html | tutorial ]]. | |
| |
| ==== Running an Executable .jar File ==== | ==== Running an Executable .jar File ==== |
| |
| - Open a command shell/terminal window. | - Open a command shell/terminal window. |
| - Change the working directory to the directory that contains the ''%%.jar%%'' file (using the ''%%cd%%'' command) | - Change the working directory to the directory that contains the ''%%.jar%%'' file (using the [[https://ss64.com/|cd command]]) |
| - Execute the application as follows: ''%% java -jar //filename//.jar %%'' | - Execute the application as follows: ''java -jar //filename//.jar'' |
| |
| You can also run an executable .jar file from a file explorer/finder by double-clicking on it. However, your associations and permissions must first be setup. | You can also run an executable .jar file from a file explorer/finder by double-clicking on it. However, your associations and permissions must first be setup. |
| ===== Permissions and Executable .jar Files ===== | ===== Permissions and Executable .jar Files ===== |
| |
| Depending on your operating system, you may need to change the permissions of the executable ''%%.jar%%'' file (i.e., provide permission to execute). In most OSs this can be done from the command line (using ''%%chmod%%'') or from the GUI (in a variety of different ways). | Depending on your operating system, you may need to change the permissions of the executable ''%%.jar%%'' file (i.e., provide permission to execute). In most OSs this can be done from the command line (using the [[https://ss64.com/|chmod command]]) or from the GUI (in a variety of different ways). |
| |
| ===== Associations and Executable .jar Files ===== | ===== Associations and Executable .jar Files ===== |