|
JAR FILE
ABOUT JAR FILES JAR, which stands for Java Archive, is a package format
that groups different Java files into a single file. The Runnable JAR file can be double clicked
on to run the Java Application. java -jar filename.jar BATCH FILE If you have a console application in a JAR file and you
want to be able to double click on a file to run it, you could create a BATCH
file.
Now, double clicking on the batch file will run the FunJar.jar file using java.exe which will open a terminal window and show console output in it. HOW TO CREATE A RUNNABLE JAR FILE IN ECLIPSE 1-First, make sure you’ve run your program at least once in Eclipse. 2-Right click on your project in the Package Explorer and select Export. 3-Under Java, choose Runnable Jar File and click Next. 4-Choose the correct Launch configuration (the class that contains your main method). 5-Set the Export destination by clicking Browse and naming
your file (e.g., MyApp.jar). 6-Under Library handling, select "Extract required
libraries into generated JAR" to include dependencies. 7-Click Finish. 8-Done. Now go to the location and try running your JAR file. Remember that if you program is a console application, you will need to either run it in the terminal or create a batch file. FURTHER TESTING We still need to check how an external text file works here. Does it get placed inside the JAR file? Does it need to be placed in the same folder as the JAR file? Or perhaps using a specific path relative to the JAR file?
|