Index
- What is SophiaCompress(Java) OASIS?
- System Requirements
- Installation
- Compression Through Graphical User Interface
- Command-line User Interface
- Using Eclipse
- Error Messages and Restrictions
- Compression Methods
- Support
- Glossary
1 What is SophiaCompress(Java) OASIS?
SophiaCompress(Java) OASIS is a compression tool for mobile Java applications with MIDP or Star / DoJa profile, that minimizes the size of a JAR file.
The Steps to Compress a mobile Java Application
- Unpacking JAR file
- Compressing
- Preverifying
- Re-packing to JAR file
- Modifying ADF file
2 System Requirements
2.1 System Environments
OS: | Windows 7 / XP |
Java for developing applications: | Java 2 SDK 1.3.1 / 1.4.2 |
Java for booting up SophiaCompress(Java) OASIS: | JRE 1.5.0 |
Eclipse: | Eclipse 3.2.1 |
2.2 Profiles
NTT DoCoMo : DoJa-1.0
Preverifier:
Attached to J2ME Wireless SDK for the DoJa-1.0 release2.2 ( preverify.exe )
Library:
Attached to J2ME Wireless SDK for the DoJa-1.0 release2.2 ( dojaapi.jar )
NTT DoCoMo : DoJa-2.0
Preverifier:
Attached to i-Appli Development Kit for DoJa-2.0 Ver.1.03 ( preverify.exe )
Library:
Attached to i-Appli Development Kit for DoJa-2.0 Ver.1.03 ( classes.zip, doja_classes.zip )
NTT DoCoMo : DoJa-3.0
Preverifier:
Attached to i-Appli Development Kit for DoJa-3.0 Ver.2.00 ( preverify.exe )
Library:
Attached to i-Appli Development Kit for DoJa-3.0 Ver.2.00 ( classes.zip, doja_classes.zip )
NTT DoCoMo : DoJa-3.5
Preverifier:
Attached to i-Appli Development Kit for DoJa-3.5 Ver.1.03 ( preverify.exe )
Library:
Attached to i-Appli Development Kit for DoJa-3.5 Ver.1.03 ( classes.zip, doja_classes.zip )
NTT DoCoMo : DoJa-4.0
Preverifier:
Attached to i-Appli Development Kit for DoJa-4.0 Ver.1.03 ( preverify.exe )
Library:
Attached to i-Appli Development Kit for DoJa-4.0 Ver.1.03 ( classes.zip, doja_classes.zip )
NTT DoCoMo : DoJa-4.1
Preverifier:
Attached to i-Appli Development Kit for DoJa-4.1 Ver.1.11 ( preverify.exe )
Library:
Attached to i-Appli Development Kit for DoJa-4.1 Ver.1.11 ( classes.zip, doja_classes.zip )
NTT DoCoMo : DoJa-5.0
Preverifier:
Attached to i-Appli Development Kit for DoJa-5.0 Ver.1.05 ( preverify.exe )
Library:
Attached to i-Appli Development Kit for DoJa-5.0 Ver.1.05 ( classes.zip, doja_classes.zip )
NTT DoCoMo : DoJa-5.1
Preverifier:
Attached to i-Appli Development Kit for DoJa-5.1 Ver.3.00 ( preverify.exe )
Library:
Attached to i-Appli Development Kit for DoJa-5.1 Ver.3.00 ( classes.zip, doja_classes.zip )
NTT DoCoMo : Star-1.0
Preverifier:
Attached to i-Appli Development Kit for Star-1.0 Ver.1.00 ( preverify.exe )
Library:
Attached to i-Appli Development Kit for Star-1.0 Ver.1.00 ( classes.zip, star_classes.zip )
au EZ-Appli( Java )
Preverifier:
Attached to Java 2 Platform Micro Edition Wireless Toolkit version 1.0.4_01 for Windows ( preverify.exe )
Library:
Attached to EZ-Appli( Java ) development kit ( ezplus Emulator version 1.0 ) ( kddip.jar )
J2ME Wireless Toolkit version 1.0.4_01 for Windows ( midpapi.zip )
KJX maker:
Attached to EZ-Appli( Java ) development kit ( ezplus Emulator version 1.0 ) ( KJXArchiver.jar )
SoftBank S! Appli
Preverifier:
Attached to S! appli Emulator for JSCL 1.3.2 Ver.1.0.1 ( preverify.exe )
Library:
Attached to S! appli Emulator for JSCL 1.3.2 Ver.1.0.1 (stubclasses.zip)
SoftBank S! Appli ( MIDP 2.0 )
Preverifier:
Attached to J2ME Wireless Toolkit version 1.0.4_01 for Windows ( preverify.exe )
Library:
Attached to MEXA Emulator Version 1.1.0 (stubclasses.zip)
Motorola Java
Preverifier:
Attached to Motorola SDK v4.3 for J2ME ( preverify.exe )
Library:
Attached to Motorola SDK v4.3 for J2ME ( javaextensions.jar, stubclasses.zip )
Nokia Java
Preverifier:
Attached to Nokia Developer's Suite 2.2 for J2ME ( preverify.exe )
Library:
Attached to Nokia Developer's Suite 2.2 for J2ME ( classes.zip )
Samsung Java
Preverifier:
Attached to J2ME Wireless Toolkit version 1.0.4_01 for Windows ( preverify.exe )
Library:
Attached to Samsung JSDK ( SamsungApi.jar )
KDDI OpenAppli Java
Preverifier:
Attached to Java(TM) Wireless Toolkit version 2.5 for CLDC( preverify.exe )
Library:
Attached to Java(TM) Wireless Toolkit version 2.5 for CLDC ( *.jar )
2.3 Unsupported Environments
The J2ME Wireless Toolkit version 1.0.1 preverifier is not supported by SophiaCompress(Java) OASIS.
2.4 Web Sites for Downloading Mobile Java SDK
J2SE
J2SE 1.3.1 / J2SE 1.4.2 / J2SE 5.0
Archive: Java[tm] Technology Products Download
Eclipse
http://www.eclipse.org/downloads/index.php
Software Development Kit for Mobile Java Applications
NTT DoCoMo i-Appli Development Kit:
http://www.nttdocomo.co.jp/english/p_s/i/make/index.html
au EZ-Appli( Java ) Development Kit ( Japanese ):
http://www.au.kddi.com/ezfactory/tec/spec/ezplus_kit.html
J2Softbank S! Appli Development Kit ( Japanese ):
http://developers.softbankmobile.co.jp/dp/tool_dl/java/tool.php
J2ME Wireless Toolkit:
http://java.sun.com/products/j2mewtoolkit/
Java(TM) Wireless Toolkit version 2.5 :
http://java.sun.com/products/sjwtoolkit/download-2_5.html
3 Installation
To install, double-click the installer icon. An InstallShield wizard will take over to guide you through the installation.
4 Compression Through Graphical User Interface
Booting Up SophiaCompress(Java) OASIS.
SophiaCompress(Java) OASIS is booted up, using one of the 3 following methods.
- Double-clicking on the SophiaCompress(Java) OASIS icon.
- Selecting SophiaCompress(Java) OASIS from the Windows menu
- Double-clicking scompress.jar inside the installed folder.
Main window ( at boot up ) of SophiaCompress(Java) OASIS
4.1 Menu
[File]
- [Preferences...]: the [Preferences] window is used to set up the configurations for compression
- [Upgrade edition]: activates the license file for an upgraded edition
- [Exit]: exits SophiaCompress(Java) OASIS
[Help]
- [Brief help on/off]: shows / hides Brief Help Panel at the bottom of the window
- [License File Information...]: displays information concerning user's license file
- [About SCJ OASIS ...]: displays information about SophiaCompress(Java) OASIS
4.2 Configuration
4.2.1 Java Settings:
[Java SDK]: |
If [Java SDK] is empty, set up the JAVA_HOME path where Java SDK is installed using the [select] button.
The JAVA_HOME path can be set up by selecting the path of bin\java.exe in the Java SDK, for example C:\j2sdk1.4.2_08\bin\java.exe.
The supported version of Java SDK is 1.3.1 or 1.4.2.
[Archiver]: |
Setting up the Compression Tool.
1. [JAR]
bin/jar.exe is used in the Java SDK. ( JAR ( bin/jar.exe ) is recommended. )
2. [7-ZIP]
3. [kzip]
4. [other ZIP]
Select the [ZIP path] of the compression tool, and set up its [ZIP parameters]. Enter %1 as the input folder, and %2 as the output file.
* If [7-ZIP] or [kzip] is selected, [ZIP Parameters] are automatically set up as follows.
Program: | 7-ZIP (http://www.7-zip.org/) |
[ZIP path]: | 7z.exe |
[ZIP parameters]: | a -tzip -mx=9 %2 %1 |
Program: | kzip (http://advsys.net/ken/utils.htm) |
[ZIP path]: | kzip.exe |
[ZIP parameters]: | /r %2 * |
4.2.2 Profile Settings:
* [Profile]: Only profiles that have been checked are included in the profile list of the main window.
[Preverifier]: |
- Outer: the preverifier specified in the [Preverifier Path] ( * recommended )
- Inner: the preverifier of SophiaCompress(Java) OASIS
[Preverifier Path]: |
[Preverifier Path] is valid when the Outer option is selected. The preverifier attached to the mobile Java SDK should be selected.
[Libraries Needed for Mobile Compression]: |
Listing Class Libraries Referred to by the Application.
[Add] button:
A library can be added to the list of [Libraries Needed for Mobile Compression] with the [Add] button.
[Remove] button:
A library can be removed from the list of [Libraries Needed for Mobile Compression] with the [Remove] button.
* In general, class libraries are in the /lib folder of the mobile Java SDK.
*NOTICE : In case of NTT DoCoMo Star / DoJa, dbgclasses.zip in the /lib folder is a library for debugging and it must not be added.
[EZ Appli] ( Java )
[Create KJX File]: |
A KJX file is generated when [Create KJX File] is checked, and a [KJX Maker] path is selected.
[Add CRC]: |
CRC information is added to the compressed application when [Add CRC] checked and the path of a [CRC Maker] is selected.
MIDP
Open Appli
[Encoding]: |
By default, ASCII encoding is selected to read / write the JAD file. Other types of encoding can be selected from the list of [Encoding], or the type's Canonical Name can be directly entered in the [Encoding] field. However, since the JAD file of KDDI's OpenAppli must be specified in UTF8, there is only UTF8 in the [Encoding] field.
Additional information about canonical encoding names
4.2.3 Compression Options:
* If [Shorten Class Names] is checked, a new main class name may be entered in [New Main Class Name] and saved with the [Change] button.
* The [Class Integration] or [Optimize Stack Map] ( Make New Class ) options may increase the compressed application's memory consumption during execution. If OutOfMemoryError occurs, [Integration Level] should be lowered, or both these options turned off.
4.3 Application Compression
- The [Import] button is used to select an application file in JAR or a folder containing many JAR files for compression. A file / folder can also be selected by Drag & Drop.
*NOTICE : The jar file for "Full+Mini Appli" and "Mini + Full Appli" of NTT DoCoMo Star Profile is not supported. To compress it, specify the jar file for "Full Appli" or "Mini Appli" separately.
The application Profile should be selected in the lower left corner [Combobox].
Compression starts the [Compress] button is clicked. Detailed compression information is displayed when the [View log] button is pressed.
[Done] : status after compression
: Compression was completed without errors.
: Compression finished but a preverifier error occurred.
: An error occurred during compression.
[No] : ordinal number
[JAR] : application name
[JAM/JAD] : checked when an ADF file with the same name as JAR is found in the folder
[Input] : byte size of the JAR file before compression
[Output] : byte size of the JAR file after compression
[%] : compression rate
4.4 Brief Help Panel
When the [Brief Help Panel] is enabled from [Help] menu, help information on UI components is displayed as the mouse cursor moves over them.
5 Command-Line User Interface
5.1 Startup Command
The startup command is as follows:
java -jar scompress.jar -profile_name input.adf input.jar [-o output.dir] [-java javaPath] [-jar JAR/7ZIP/kzip/ZIP] [-7ZIP path] [-kzip path] [-zip ZIP] [-zip_command "..."] [-pvf preverifier] [-f] [-kjx kjxmaker] [-crc crcadder] [-encoding encoding_name] [-cp classpath;...] [-icc] [-usepvf SDK/SCJ] [-mainclass MAINCLASS] [-op_???? on/off]
*NOTICE : The jar file for "Full+Mini Appli" and "Mini + Full Appli" of NTT DoCoMo Star Profile is not supported. To compress it, specify the jar file for "Full Appli" or "Mini Appli" separately.
-profile_name: (* required )
-docomo | i-Appli ( input.adf file is in JAM format ) |
-ezplus | EZ-Appli(Java) ( input.adf file is in JAD format ) |
-softbank / -vodafone | S! Appli ( input.adf file is in JAD format ) |
-willcom | WILLCOM ( input.adf file is in JAD format ) |
-motorola | Motorola ( input.adf file is in JAD format ) |
-nokia | Nokia ( input.adf file is in JAD format ) |
-samsung | Samsung ( input.adf file is in JAD format ) |
-midp | MIDP in general ( input.adf file is in JAD format ) |
-openappli | OpenAppli in general ( input.adf file is in JAD format ) |
Other parameters:
The following parameters are automatically set up in the Configuration Files created when using the GUI edition of SophiaCompress(Java) OASIS, but they can also be manually specified.
-o | folder name for output |
-java | set the JDK ( folder where the JDK is installed ) | -jar JAR/7ZIP/kzip/ZIP | select JAR compression tool ( JAR, 7ZIP, kzip, or ZIP ) |
-7ZIP path | set the 7-ZIP |
-kzip path | set the kzip |
-zip ZIP | set the ZIP tool |
-zip_command "..." | 1% is input folder / 2% is output file |
-usepvf SDK/SCJ | select the Preverifier type : SDK ( Outer ) or SCJ ( Inner ) |
-pvf | set the Preverifier when -usepvf SDK is selected |
-kjx | set the KJX Maker when -ezplus option is selected |
-crc | set the CRC Maker when -ezplus option is selected |
-encoding | set the encoding name of JAD file when -midp or -openappli option is selected |
-icc | ignore all library paths in the profiles.cfg configuration file or effective in the previous commands |
-cp | set class libraries not in the profiles.cfg configuration file and referred to by an application ( multiple library paths must be separated by a semi-colon ";" ) |
-f | set the compulsory mode: ignore all the warning messages such as file override |
-mainclass | set the main class name after compression |
-op_XXXX on/off | set/reset the compression method with on or off ( XXXX is replaced with the compression method name below. By default, these all values are on except op_gc(). ) |
-op_unite | select the option of class integration |
-op_unite_abstract | select the option of abstract class integration |
-op_unite_level [1-10] | set the class integration level ( integer from 1 to 10 ) |
-op_nop | delete NOP instructions |
-op_deadcode | delete unused codes |
-op_exception | delete unnecessary try - catch exception tables |
-op_goto | delete / rewrite goto statements |
-op_print | delete System.out.print[ln] |
-op_stack | delete unnecessary stack operations |
-op_inline | expand inline methods |
-op_array | merge class variables into an array |
-op_interface | delete unnecessary interfaces |
-op_class | delete unused classes |
-op_method | delete unused methods |
-op_classrename | shorten class names |
-op_share | share names |
-op_share_field | share names - share field names forcely |
-op_share_method | share names - share method names forcely |
-op_sort_cp | sort constant pool entries |
-op_access_flag | modify access flags |
-op_return_value | delete unused return values |
-op_basic_block | share Basic Block |
-op_switch | replace switch with if |
-op_stackmap | optimize StackMap |
-op_share_method | share methods |
-op_synchronized | synchronize methods |
-op_init | remove unused initialization codes |
-op_string | optimize strings |
-op_method_declare | optimize methods declaration |
-op_class_vars_to_static | change variables into static |
-op_stackmap_new_class | optimize StackMap with a new class |
-op_gc | delete gc() |
-op_jdk1_4 | support JDK 1.4(Java 2 SDK 1.4.2) ( an application made with JDK 1.4(Java 2 SDK 1.4.2) can be compressed when -op_jdk1_4 is selected ) |
Version of SophiaCompress(Java) OASIS
-version | display the version of SophiaCompress(Java) OASIS |
* Only [-version] should be specified.
5.2 Examples
Example1: compression with the profiles.cfg
i-Appli
java -jar scompress.jar -docomo hoge.jam hoge.jar
EZ Appli( Java )
java -jar scompress.jar -ezplus hoge.jad hoge.jar
S! Appli
java -jar scompress.jar -softbank hoge.jad hoge.jar
Open Appli
java -jar scompress.jar -openappli hoge.jad hoge.jar
Example2: compression of S! Appli referring to only the mylib.jar library
S! Appli
java -jar scompress.jar -icc -cp mylib.jar -softbank hoge.jad hoge.jar
Example3: disabling CRC maker, while CRC maker is set up in the profiles.cfg
EZ-Appli(Java)
java -jar scompress.jar -crc "" -ezplus hoge.jad hoge.jar
* A NULL string should be specified as CRC maker.
5.3 Configuration Files
Configuration Files are .cfg text files in the same folder as scompress.jar generated when the GUI edition of SophiaCompress(Java) OASIS is used for the first time.
General.cfg: Settings for Java and GUI
SHOW_BRIEF_HELP = true JAVA_SDK_FOLDER = C:\jdk1.3.1_13 JAR_ARCHIVER = JAR 7-ZIP_FOLDER =C:\Program Files\7-Zip\7z.exe KZIP_FOLDER =C:\Program Files\kzip.exe ZIP_FOLDER = C:\Program Files\7-Zip\7z.exe ZIP_PARAMETERS = a -tzip -mx=9 %2 %1 START_PROFILE = DoCoMo LAST_TARGET = INPUT_PATH =
Parameters of general.cfg:
- SHOW_BRIEF_HELP
- flag to display the Brief Help Panel ( effective only for the GUI edition )
- JAVA_SDK_FOLDER
- JDK path ( the folder where the JDK is installed )
- JAR_ARCHIVER
- JAR compression tool ( JAR, 7ZIP, kzip, or ZIP )
- 7-ZIP_FOLDER
- 7-ZIP path
- KZIP_FOLDER
- kzip path
- ZIP_FOLDER
- ZIP tool path
- ZIP_PARAMETERS
- parameters of ZIP tool ( 1% is input folder / 2% is output file )
- START_PROFILE
- initial profile name ( SophiaCompress(Java) OASIS internal parameter, effective only for GUI edition )
- LAST_TARGET
- last selected file ( SophiaCompress(Java) OASIS internal parameter, effective only for GUI edition )
- INPUT_PATH
- last compressed application ( SophiaCompress(Java) OASIS internal parameter, effective only for GUI edition )
Profiles.cfg: Settings for Profiles
DoCoMo_ENABLED = true DoCoMo_SDKPREVERIFIER = true DoCoMo_PREVERIFIER_FILE_PATH = C:\iDKDoJa3.5\bin\preverify.exe DoCoMo_LIBRARIES = C:\iDKDoJa3.5\lib\doja_classes.zip; C:\iDKDoJa3.5\lib\classes.zip S!Appli_ENABLED = true S!Appli_SDKPREVERIFIER = true S!Appli_PREVERIFIER_FILE_PATH = C:\V-appli_SDK_122\bin\preverify.exe S!Appli_LIBRARIES = C:\V-appli_SDK_122\lib\stubclasses.zip Willcom_ENABLED = true Willcom_SDKPREVERIFIER = true Willcom_PREVERIFIER_FILE_PATH = Willcom_LIBRARIES = EZAppli_ENABLED = true EZAppli_SDKPREVERIFIER = true EZAppli_PREVERIFIER_FILE_PATH = C:\WTK104\bin\preverify.exe EZAppli_LIBRARIES = C:\WTK104\lib\midpapi.zip; C:\EZAppli_SDK\lib\kddip3.jar EZAppli_CREATE_KJX_FILE = true EZAppli_ADD_CRC = false EZAppli_KJX_MAKER_PATH = C:\EZAppli_SDK\bin\KJXArchiver.jar EZAppli_CRC_MAKER_PATH = Nokia_ENABLED = true Nokia_SDKPREVERIFIER = true Nokia_PREVERIFIER_FILE_PATH = C:\Nokia\Devices\ Series_60_MIDP_Concept_SDK_Beta_0_3_1_Nokia_edition\bin\preverify.exe Nokia_LIBRARIES = C:\Nokia\Devices\ Series_60_MIDP_Concept_SDK_Beta_0_3_1_Nokia_edition\lib\classes.zip Motorola_ENABLED = true Motorola_SDKPREVERIFIER = true Motorola_PREVERIFIER_FILE_PATH = C:\Program Files\Motorola\ SDK v4.3 for J2ME\EmulatorA.1\bin\preverify.exe Motorola_LIBRARIES = C:\Program Files\Motorola\SDK v4.3 for J2ME\ EmulatorA.1\lib\javaextensions.jar;C:\Program Files\Motorola\ SDK v4.3 for J2ME\EmulatorA.1\lib\stubclasses.zip Samsung_ENABLED = true Samsung_SDKPREVERIFIER = true Samsung_PREVERIFIER_FILE_PATH = C:\WTK104\bin\preverify.exe Samsung_LIBRARIES = C:\Program Files\Samsung\SJSDKv2.0\lib\SamsungApi.jar MIDP_ENABLED = true MIDP_SDKPREVERIFIER = true MIDP_PREVERIFIER_FILE_PATH = C:\WTK104\bin\preverify.exe MIDP_LIBRARIES = C:\WTK104\lib\midpapi.zip MIDP_ENCODING = UTF8 OpenAppli_ENABLED = true OpenAppli_SDKPREVERIFIER = true OpenAppli_PREVERIFIER_FILE_PATH = C:\WTK25\bin\preverify.exe OpenAppli_LIBRARIES = C:\WTK25\lib\cldcapi10.jar;C:\WTK25\lib\cldcapi11.jar;C:\WTK25\lib\j2me-ws.jar;C:\WTK25\lib\j2me-xmlrpc.jar;C:\WTK25\lib\jsr082.jar;C:\WTK25\lib\jsr179.jar;C:\WTK25\lib\jsr180.jar;C:\WTK25\lib\jsr184.jar;C:\WTK25\lib\jsr211.jar;C:\WTK25\lib\jsr226.jar;C:\WTK25\lib\jsr229.jar;C:\WTK25\lib\jsr234.jar;C:\WTK25\lib\jsr238.jar;C:\WTK25\lib\jsr239.jar;C:\WTK25\lib\jsr75.jar;C:\WTK25\lib\midpapi10.jar;C:\WTK25\lib\midpapi20.jar;C:\WTK25\lib\midpapi21.jar;C:\WTK25\lib\mmapi.jar;C:\WTK25\lib\satsa-apu.jar;C:\WTK25\lib\satsa-crypto.jar;C:\WTK25\lib\satsa-jcrmi.jar;C:\WTK25lib\satsa-pki.jar;C:\WTK25\lib\wma11.jar;C:\WTK25\lib\wma20.jar OpenAppli_ENCODING = UTF8
Parameters of profiles.cfg:
- ENABLED
- availablity of the profile in the profile list of the main window ( effective only for the GUI edition )
- SDKPREVERIFIER
- if this flag is set to true, the SDK preverifier specified in PREVERIFIER_FILE_PATH is used. If false, preverifier of SophiaCompress(Java) OASIS is used.
- PREVERIFIER_FILE_PATH
- Preverifier path
- LIBRARIES
- class libraries referred to by an application to be compressed ( multiple library paths must be separated by a semi-colon ";" )
- CREATE_KJX_FILE
- flag to create KJX file: true or false
- ADD_CRC
- flag to add the CRC information on the KJX file: true or false
- KJX_MAKER_PATH
- KJX maker path
- CRC_MAKER_PATH
- CRC maker path
- ENCODING
- encoding name of the JAD file ( effective only for the MIDP profile )
compression.cfg:settings example
CLASS_INTEGRATION_ABSTRACT = true INTEGRATION_RATIO = 10 NEW_CLASS_NAME = SHARE_FIELD_NAMES_FORCELY = true SHARE_METHOD_NAMES_FORCELY = true CLASS_INTEGRATION = true SHARE_CLASS_NAMES = true SHARE_NAMES = true JDK_OVER_1_4 = true UNUSED_CLASSES = true UNUSED_INTERFACES = false UNUSED_METHODS = true UNUSED_CODE = true UNUSED_EXCEPTIONAL_TABLE = true GOTO_JUMPS = true UNUSED_STACK_OPERATION = true INLINE_METHOD_DEPLOYMENT = true CLASS_VARIABLES_INTO_ARRAY = true SORT_CP = true ACCESS_FLAGS = true UNUSED_RETURN_VALUE = true DELETE_SYSTEM_OUT_PRINTLN = true SHARE_BASIC_BLOCK = true SWITCH_TO_IF = true OPTIMIZE_STACK_MAP = true SHARE_METHODS = true MAKE_SYNCHRONIZED_METHOD = true UNUSED_INITIALIZE = true OPTIMIZE_STRING = true OPTIMIZE_METHOD_DECLARATION = true CLASS_VARIABLES_TO_STATIC = true DELETE_NOP = true OPTIMIZE_STACKMAP_NEW_CLASS = false DELETE_GC() = false
Parameters of compression.cfg:
- CLASS_INTEGRATION_ABSTRACT
- integrate abstract classes
- INTEGRATION_RATIO
- set the class integration level ( integer from 1 to 10 )
- NEW_CLASS_NAME
- set New Main Class Name after compression
- SHARE_FIELD_NAMES_FORCELY
- share names - share field names forcely
- SHARE_METHOD_NAMES_FORCELY
- share names - share method names forcely
- CLASS_INTEGRATION
- integrate classes
- SHARE_CLASS_NAMES
- share class names
- SHARE_NAMES
- share names between classes
- JDK_OVER_1_4
- support JDK 1.4(Java 2 SDK 1.4.2) ( an application made with JDK 1.4(Java 2 SDK 1.4.2) can be compressed when -op_jdk1_4 is selected )
- UNUSED_CLASSES
- delete unused classes
- UNUSED_INTERFACES
- delete unnecessary interfaces
- UNUSED_METHODS
- delete unused methods
- UNUSED_CODE
- delete unused codes
- UNUSED_EXCEPTIONAL_TABLE
- delete unnecessary try - catch exceptional tables
- GOTO_JUMPS
- delete / rewrite goto instructions
- UNUSED_STACK_OPERATION
- delete unnecessary stack operations
- INLINE_METHOD_DEPLOYMENT
- expand inline methods
- CLASS_VARIABLES_INTO_ARRAY
- merge class variables into an array
- SORT_CP
- Sort constant pool entries
- ACCESS_FLAGS
- modify access flags
- UNUSED_RETURN_VALUE
- delete unused return values
- DELETE_SYSTEM_OUT_PRINTLN
- delete System.out.print[ln]
- SHARE_BASIC_BLOCK
- share Basic Block
- SWITCH_TO_IF
- replace switch with if
- OPTIMIZE_STACKMAP
- optimize StackMap
- SHARE_METHODS
- share method
- MAKE_SYNCHRONIZED_METHOD
- make synchronized method
- UNUSED_INITIALIZE
- delete unused initialization codes
- OPTIMIZE_STRING
- optimize strings
- OPTIMIZE_METHOD_DECLARATION
- optimize method declaration
- DELETE_NOP
- delete NOP instructions
- CLASS_VARIABLES_TO_STATIC
- delete NOP instructions
- OPTIMIZE_STACKMAP_NEW_CLASS
- optimize StackMap with a new class
- DELETE_GC()
- delete gc() ( garbage collecting instruction )
* The parameters except INTEGRATION_RATIO and NEW_CLASS_NAME are set up by true or false.
* A compression method is enabled / disabled by entering either true / false.
Reading cfg files
When the CUI boots up, a configuration file reads the cfg file of the current folder. If it is not found in the current folder, a cfg file is read from the folder containing scompress.jar. A cfg file is not read if not found in these two folders.
6 Using Eclipse
Applications can be compressed using Eclipse if the Eclipse plug-in for SophiaCompress(Java) OASIS is installed.
6.1 Installation of Eclipse Plug-in
Install the Eclipse plug-in with the SophiaCompress(Java) OASIS installer.
* The plug-in can also be installed by copying the com.s_cradle.sophiacompress.eclipse.plugin_1.0.0.jar file into the plugins folder of Eclipse.
6.2 Settings
To set up the plug-in path, select the Eclipse menu [Window] - [Preferences...].
At [SCJ Path], the file scompress/scompress.jar is set up in the SophiaCompress(Java) OASIS folder.
The Profile of the applications that will be compressed is selected in [Profile].
SophiaCompress(Java) OASIS preferences, must be set prior to compression.
6.3 Compression
Right-clicking a Java project in the [Package Explorer] window of Eclipse chooses it.
Selecting [Compress] from the menu, starts the compression of the JAR file and the ADF file in the bin or deployed folder of the project.
7 Error Messages and Restrictions
7.1 Error Messages
7.1.1 java.lang.OutOfMemoryError
- Cause:
- A shortage of heap memory for the Java system leads to compression failure.
- Provision:
- The Java heap memory size may be increased by booting up SophiaCompress(Java) OASIS with the option -Xmx<size>. The actual size of the heap is specified in <size>.
java -jar -Xmx<size> scompress.jar
- Example:
java -jar -Xmx100m scompress.jar
* This boot up option is entered as -Xmx100m, and not -Xmx<100m>.
7.1.2 java.lang.StackOverflowError
- Cause:
- A shortage of stack memory for the Java system leads to compression failure.
- Provision:
- The Java stack memory size may be increased by booting up SophiaCompress(Java) OASIS with the option -Xss<size>. The actual size of the stack is specified in <size>.
java -jar -Xss<size> scompress.jar
- Example:
java -jar -Xss50m scompress.jar
* This boot up option is entered as -Xss50m, and not -Xss<50m>.
7.2 Restrictions
7.2.1 Double-byte Characters in the File Path
SophiaCompress(Java) OASIS may not operate correctly if double-byte characters ( e.g. Kanji ) are used in the absolute path of a JAR file to be compressed.
7.2.2 Class.forName Method
An application that uses a Class.forName method, may not function correctly after compression.
Example:
- When the application refers to class names that are dynamically made by String operations.
- When the class name appears as a string, on the screen of the mobile phone.
7.2.3 Lack of Memory After Compression
- Cause:
- The Class Integration and Optimize StackMap ( Make New Class ) methods may increase the memory consumption of the application after compression, make it terminate during execution with an OutOfMemoryError, and may also cause the Garbage Collector to run more frequently, slowing down the application.
- Provision:
- Integration Level should be lowered or the Class Integration and Optimize StackMap methods should be turned off.
7.2.4 Resource File Paths
- Cause:
- The Class Integration and Shorten Class Names methods may change absolute class paths. If resource files are accessed through relative class paths, the compressed application may fail to access them.
- Provision:
- Resource files should be accessed through their absolute paths.
Example: code from application.text
Not Recommended: InputStream inputStream = getClass().getResourceAsStream("input.txt")
Recommended: InputStream inputStream = getClass().getResourceAsStream("/application/text/input.txt")
7.2.5 JAM File With Icon Characters ( for NTT DoCoMo's Star / DoJa )
- Cause:
- SophiaCompress(Java) OASIS cannot handle picture characters encoded with SJIS_i.
- Provision:
- The SJIS_i18n.jar file of JDK is modified to handle the SJIS_i encoding as follows.
Modifying i18n.jar file:
- Backup the original i18n.jar.
i18n.jar will exist in one of the following paths.- %JAVA_HOME%\lib\i18n.jar
- %JAVA_HOME%\jre\lib\i18n.jar
- Unpack the i18n.jar file onto the i18n folder.
- Replace the i18n folder with the i18n folder in the %IDK_HOME%/lib folder.
- Compress the i18n folder and name it i18n.jar.
- Replace the i18n.jar file in the original folder with the i18n.jar file in the Step 4.
* %JAVA_HOME% is the folder where JDK was installed and %IDK_HOME% is the folder where the i-Appli development kit was installed.
7.2.6 External Programs Syntax
- Preverifier:
- preverifier.exe [-classpath 'classpath'] -d output input
- KJX Maker:
- java -jar KJXMaker.jar -c inputJad inputJAR outputKJX (in case of JAR file )
KJXMaker.exe -c inputJad inputJAR outputKJX ( in case of EXE file ) - CRC Maker:
- java -jar CRCMaker.jar targetKJX (in case of JAR file )
CRCMaker.exe targetKJX ( in case of EXE file )
7.2.7 Window Size
When the window size is too small to use, SophiaCompress(Java) OASIS may be booted up with the -resize option specified.
java -jar scompress.jar -resize
Example:
8 Compression Methods
8.1 Data Optimization
Deleting unnecessary attrubutes
Delete attributes added by the preverifier such as Synthetic, InnerClass, Deprecated, StackMap, which are irrelevant to program execution.
Deleting unused constants
Delete the unused entries in the constant pool that are caused by sharing and abbreviating names. Constant pool is a data area for managing constant names or values in a program
Deleting irrelevant fields
Delete the fields irrelevant to program execution.
Deleting irrelevant methods
Delete the methods irrelevant to program execution.
Deleting irrelevant classes
Delete the classes irrelevant to program execution.
Deleting interfaces
Reorganize and delete the interfaces
Deleting irrelevant return values
Delete the return values that are irrelevant to program execution and make the return type of the method void.
Deleting unused initialization codes
Delete the initialization codes of fields and arrays that are irrelevant to program execution.
Sharing and shortening field names
Share and abbreviate the class field names.
Sharing and shortening method names
Share and abbreviate the method names.
Sorting constant pool entries
Sort the entries in the constant pool for efficiency of the ZIP compression.
Arranging class variables
Merge the class variables into an array.
Sharing class names
Share and abbreviate the class names.
8.2 Instructions Optimization
Deleting nop instructions
Delete the nop instructions.
Deleting unused code
Delete the unused codes (dead codes).
Deleting unnecessary try-catch blocks
Delete the unnecessary try - catch exception tables.
Deleting and rewriting goto instructions
Delete the goto instructions that will jump into next instruction, and rewrite the target of the goto instruction that will jump on another goto instruction.
Deleting System.out.print instructions
Delete the System.out.print and System.out.println instructions.
Changing local variable order
Change the order of the local variables so that the local variables frequently referred to may be moved into the beginning position of the array for variables.
Deleting unused stack values
Delete unnecessary codes that will push a value onto stack and pop it up without referring to.
In-line method expansion
Expand and delete the methods that are small or called at the only one position.
Modifying access flags
Modify the access flags of the classes, methods and fields for the efficiency of the ZIP compression.
Replacing switch with if
Replace the switch instruction with less than two branches with the if instruction.
Sharing methods
Share the methods with the same codes.
Making synchronized methods
Make the new synchronized methods from the synchronized statements.
Optimizing strings
Replace strings that are made in programs dynamicaly with constant strings if they are able to be calculated.
Optimizing method declarations
Change instance methods into static methods if possible.
Changing instance fields into class fields
Change instance fields of application class into class fields.
Deleting gc() instructions
Delete System.gc() and Runtime.getRuntime().gc().
Supporting JDK 1.4
Support the JDK 1.4 so that an application made with JDK 1.4 may be compressed.
8.3 Class Integration
Two classes can be integrated into one class under some conditions, this process is repeated with other classes recursively.
8.4 StackMap Optimization
StackMap optimization
Optimze StackMap : Delete StackMap attributes appended when preverifying.
StackMap optimization ( making new classes )
Optimze StackMap ( Make New Class ) : Delete StackMap attributes appended when preverifying, and make new classes instead.
Sharing basic blocks
Share Basic Blocks : Share the Basic Block between the Basic Blocks with no jump instructions.
9 Support
If any questions, comments, suggestions, or anything else related with SophiaCompress(Java) OASIS, contact us through our Question Form.
And if a bug is found, please contact us with error information, its compression logs, screen captures, etc.
Upgrading Information
Please refer to the SophiaCompress(Java) OASIS Release Note
10 Glossary
- ADF ( Application Descriptor File ) :
- a file that contains the important information on mobile Java application such as application name and size, JAR file location, date of last modification, etc. In Star / DoJa, it is called JAM file, and in MIDP it is the JAD file.
- IDE (Integrated Development Environment):
- a set of integrated software tools for application development, which can include source code editor, compiler, debugger, graphical editor
- Preverify
- verifying the program for use before running on the mobile handset. An error will occur if the application executed on the handset without preverifying. In general, IDE always preverifies the application after compilation.
- Preverifier
- program for preverifying applications, usually in the /lib folder in JDK.
- Library
- JAR or ZIP file including classes necessary for the application execution. Some libraries are provided with the JDK, and almost all the mobile carriers and phone makers also provide their own specific class libraries usually in the /lib folder of IDE.
- Profile
- for mobile operators (Star / DoJa, V-appli, Willcom and EZ Appli), for mobile phone producers (Nokia, Motorola, Samsung) and universal MIDP - we use the term 'mobile profiles' to represent all of those types together.
- StackMap
- the attribute name of the instructions in the Java class file added when preverifying.
Java and trademarks related to Java are trademark and registered trademark of Sun Microsystems, Inc. in the United States of America and other countries. Names of companies and products are trademarks and registered trademarks of each each respective organization.
2-7 Tanaka Sekiden-cho, Sakyo-ku, Kyoto 606-8203, Japan
Sophia Cradle Incorporated
/