Jar files are created using the
jar.exe
utility program from JDK. You can make your jar file executable by defining the main class. For thist, you need to create a manifest file. A manifest file is a one-line text file with a "Main-Class" directive. For example:Main-Class: <MainClassName>
This line must end with a newline.
For example---
Step to create executablr jar filr ---
- Create a new folder MyApp and put all the java files.
- Now navigate to this folder from cmd and compile all files.( javac *.java)
- Let we hava Main.java,Class1.java and Class2.java
- Write a manifest.txt file(write the statement ,Main-Class: Main)
- Now run the jar utility(jar cvfm myjar.jar manifest.txt *.class)
- Now test your jar(myjar.jar)
run your application on one click by creating executable jar.
ReplyDelete