Does your user encounter difficulties when running javaapplications? You can create a Windows bat file or a Unix sh file to help him invoke application. But if you have a GUI, then you have a much simpler way to solve the problem.
On many modern desktops,. jar files are set to run automatically. This makes the application of jar files common to users. They download this stuff, put it on their desktops, and then click on them when they want to use it.
This magic has become surprisingly easy. Each. jar file has a manifest that is saved with the following file name:
Meta-inf/manifest. Mf
The jar command provides a-M option to specify the file to be used for the manifest. The following code is an application of this method. Let's create a jarcreator:
Jarmfmeta-inf/jarcreator.mf
Com.generationjava.tools.JarCreator.class
A very basic list contains the version number and the manufacturer, which is usually the vendor of the JDK. For example, the list in MacOSX is like this:
manifest-version:1.0
created-by:1.3.0 (applecomputer,inc.)
But the real move starts with the extra third line:
manifest-version:1.0
Main-class:com.generationjava.util.jarcreator
created-by:1.3.0 (applecomputer,inc.)
The third line provides the name of a class in which the static main function is run. It is equivalent to running Java commands that do not give any parameters in this class.
Once the jar is clicked, the main function of the Com.generationjava.util.JarCreator class will be invoked and the application will be implemented.