Recent comments

Poll

Highest Users

UserPoints
shamali4560
Mujtaba1310
Billy650
maoo_o540
Moin_iyan360

Who's new

  • usman911
  • shshzaib
  • HafizSohaib
  • savitadhiya
  • i_feel_4u

Current weather

Lahore

day-few
  • Few clouds
  • Temperature: 16 °C
  • Wind: Southwest, 11.1 km/h
  • Pressure: 1015 hPa
  • Rel. Humidity: 34%
  • Visibility: 6 kilometers
Reported on:
Tue, 01/06/2009 - 17:00

Adsense

PerfSpot

Create .JAR file by Command

Creating And Running Executable Jar Files with DOS no IDE required

==================================
Java .jar files are archive files, like .zip files, that can contain a  collection of Java artifacts including class files, source code, supporting documentation, etc. You can execute Java .jar files by
adding a manifest to the .jar file that specifies the name of the main application class. This section provides step-by-step instructions  that show you how to create and run an executable .jar file.

Steps To Create An Executable Jar File
==============================
The following steps are required to create an executable .jar file:

Step 1: Create a Java program and save the resulting .class files in the proper package structure

Step 2: Create a manifest file specifying the fully-qualified name of  the main application class

Step 3: Use the jar command to create the .jar file

Step 1: Create Your Java Program

============================
Using the Java development environment of your choice, create a Java  project as described in the previous sections of this chapter. Be sure to save the resulting .class files in the proper package directory  structure. For this example, I will use  SampleClass.class and
ApplicationClass.class. Both of these files are saved in the following  package directory structure:

com/pulpfreepress/jfa/chapter1
The only issue to note here is that if you are using Microsoft Windows the slashes would be replaced with backslashes like this:
com\pulpfreepress\jfa\chapter1

Step 2: Create Manifest File

============================
Using a text editor create a text file that contains a line specifying the fully-qualified name of the main application class. In this  example, the fully-qualified name of ApplicationClass is this:

com.pulpfreepress.jfa.chapter1.ApplicationClass
Therefore, the entry in the manifest file would then look like this:

Main-class: com.pulpfreepress.jfa.chapter1.ApplicationClass
(IMPORTANT NOTE: Type a carriage return after this line. Failure to do so results in some Microsoft Windows systems reporting a "Failed to  load Main-Class manifest attribute" error.)

Save the manifest file using any filename you choose. You do not have  to provide a filename extension. For this example, I saved the  manifest file with the name mainclass .

Step 3: Use The jar Command

============================
Now that you have created the manifest file, you are ready to use the jar command. The jar command takes the following format:

According to this jar command format, if you created the com package structure in your working directory, and you created the manifest file  named mainclass , and you wanted to name the jar file  MyApp.jar , the  actual jar command would look like this:

jar cmf mainclass MyApp.jar com
This would use the mainclass manifest file to create the  MyApp.jar file using the class files located in the 
com.pulpfreepress.jfa.chapter1 package.

Executing The jar File

============================
To execute the .jar file, use the java command with the -jar switch as
is shown here:

java -jar MyApp.jar
Figure 2-38 shows the  MyApp.jar file being executed with the java Quick Review about creating .jar
command and the -jar option.

Quick Review about creating .jar
====================

The Java jar command lets you create executable .jar files. To create an executable .jar file you need to create a manifest file that provides the fully-qualified name of the main application class.  Be sure to add an extra line to the manifest so that it work in the  Microsoft Windows environment. To execute the .jar file use the java
command with the -jar option.


Powered By SEO ignition: Internet Marketing Company