Example for Java Swing GUI by XML > Distribution
Distribution
Prepare the distribution
Now we are in the last step! In this step, all the related files will be merged into the single JAR file for the distribution. The generated JAR file should be ready for starting your application. The users can start the example editor just by:
- Double-clicking the JAR file, in case of Windows OS
- Specifying the JAR file as the argument for -jar option of java command, in case of UNIX platform
To make it possible, the following files should be merged into the single distribution JAR file:
- Compiled class hierarchy
- XML files for Swing GUI
- Image files for Swing GUI
- Property resource files
- Manifest file pointing the main class
- Abstract classes included in XMLPanelEdit
Up to the previous step, the first 3 files are already placed under the project directory and ready for to be merged. So, in this step, you will prepare the rest of them.
Property resource files
As described in the previous page, the XML file for Swing GUI need to be pointed by the property resource file. The name of the property resource file should start with the class name, and end with _language_COUNTRY.properties. For example, the property resource file for:
- com.oopreserch.example.VerySimpleEditor
- the Locale of en_US
will be:
- VerySimpleEditor_en_US.properties
Or, if you prepare the property resource for Japanese language, it will be:
- VerySimpleEditor_ja.properties
And the default property resource file is:
- VerySimpleEditor.properties
Because you cannot prepare for the property resource files for all the Locales in the world, do not forget the default one.
For details about the suffix of the property resource file, please read the related section of Java Tutorial.
In this example, you need to prepare the property resource files for:
- com.oopreserch.example.VerySimpleEditor
- com.oopreserch.example.VerySimpleAbout
- com.oopreserch.example.VerySimpleError
The default property resource files for them are:
- VerySimpleEditor.properties
- VerySimpleAbout.properties
- VerySimpleError.properties
These property resource files must specify the URL for the corresponding XML by xml_url property. All the default property resource files are already included under example directory of the distribution. Please explore them. As you notice, the properties other than xml_url are also specified.
The URL pointed by the value of xml_url will be the URL relative to project directory. Because it is the URL, not the file path, its file separator is always / (slash) independently from the file system. The URL does not includes \ (back-slash), regardless of the OS.
If you prepared the additional XML for the specific Locale, you need to prepare the property resource file for that Locale. And, the property resource file for that Locale should point your additional XML.
Manifest file
The manifest file can contain the information about JAR file and can be specified by jarcommand. If the fully qualified class name of the main class is specified in the manifest file, the main method of that class will be invoked automatically by java command.
For example, the users can start the example editor just by:
- Double-clicking the JAR file, in case of Windows OS
- Specifying the JAR file as the argument for -jar option of java command, in case of UNIX platform
In the example directory of the distribution, you will find mani.txt, which points:
- com.oopreserch.example.VerySimpleEditor
as the main class.
Abstract classes
Because your Swing application is always the subclass of one of:
- com.oopreserch.xml.util.XMLPanel_1_0
- com.oopreserch.xml.util.XMLFrame_1_0
- com.oopreserch.xml.util.XMLDialog_1_0
, the classes (and the related ones) should be shipped with your subclass. They are included in runtime.jar, which you will find in the distribution. Please copy it to your project directory and rename it as you like. In this example, please copy runtime.jar into example directory, and rename it to text_editor.jar .
Let's ship your product
Now, all the required files are placed under example directory, which is the project directory of this example. To make the distribution file for this example, just type:
jar ufm text_editor.jar mani.txt com/ gui/ image/ *.properties
In case of Windows OS, the command will be:
jar ufm text_editor.jar mani.txt com\ gui\ image\ *.properties
By these commands, all the required files are merged into text_editor.jar. And, because mani.txt is specified as the manifest file, the users can start the example editor just by:
- Double-clicking text_editor.jar, in case of Windows OS
- java -jar text_editor.jar, in case of UNIX platform
What does this mean? Yes, you are ready for shipping your product. It is easy, isn't it?
Java and all Java-based trademarks and logos are trademarks or registered of Sun Microsystems, Inc. in the United States and other countries.
ALL CONTENTS COPYRIGHT 2002, Jun Inamori. All rights reserved.
Any questions and comments are welcome to
Jun Inamori
.