Java67 - Java Program Example Tutorial Blog

Java67 - Java Program Example Tutorial Blog


How to run Java program from jar file in command line

Posted: 19 Dec 2012 04:47 AM PST

So you got a JAR file which contains your favorite Java game and you are wondering How to run Java program from JAR  file? Or you may be simply trying your hand after running Java program from command prompt and Eclipse IDE. Anyway its good to know How to execute Java program from JAR file, as JAR file is most popular way of shipping Java programs. JAR file usually contains all source and resource in form of class files, images, sound files etc. In order to run Java program from JAR file, it must be an executable JAR file i.e. it manifest file inside META-INF folder must contain a Main-class entry like Main-Class: Hello, which specify name of Java class which contains standard main method in Java. Without Main-class entry you can not run a JAR file in Java and if you try to run such jar file using jar command you will get error "Failed to load Main-Class manifest attribute from HelloWorld.jar". If you are not very much familiar with JAR file and don't know How to create an executable JAR, See this step by step tutorial on How to create executable JAR in Java. In this tutorial we will only focusing on running Java program from an executable JAR file.
Read more »


Post a Comment