Plüss   Aplulogo
     Print Text 
© 2017, V9.6


A MIDlet Packer and more

MidPak is a Windows command line utility that creates the deployment files for J2ME applications (MIDlets) running on a mobile device. It assumes that Sun's Wireless Toolkit (WTK) or a similar development kit is installed in order to have access to the library jars of J2ME and a device emulator of a real mobile device.

All parameter values and options are passed by command line arguments to allow a smooth integration in your favorite program editor or development environment (IDE) by spawning MidPak as an external tool. In order to automate the packaging, the project root directory and the MIDlet's name may be passed to MidPak by placeholders (scripting variables).

MidPak performs the following tasks in sequential order:

  • Create MIDlet's manifest file
  • Unpack optional user library jars
  • As an option, apply ProGuard obfuscator/optimizer
  • Preverify all classes
  • Pack the distribution jar file
  • Create the distribution jad (Java Application Description) file
  • As an option, run the device emulator with the created deployment files

If the editor/IDE does not provide scripting variables, MidPak may show a small GUI dialog, where the user enters the name of the MIDlet.


Command line parameters:

See installation for additional information.

Usage: java -jar MidPak.jar [-d] [-e] [-t] [-v]
[-c=<classdir>] [-b=<bindir>] [-i=<libjar>]
[-o=<proguardjar> [-r=<resdir] [-u=<url>]
[-f=<config>] [-p=<profile] [-x=<devname>]
<midletname> <projroot> <wtkroot> <libdir>

[    ] denotes optional parameters

Parameter Description
midletname Package name of the MIDlet class
(application class overriding MIDlet)
projroot Root directory of the project
used to find emulator.exe in 'bin' subdirectory
(fully qualified, no trailing separator)
wtkroot Root directory of the Wireless Tool Kit
(fully qualified, no trailing separator)
libdir Directory of all jar files needed for preverification
(fully qualified, no trailing separator)
classdir (optional) Subdirectory of projroot
where are the class files (default: 'classes')
bindir (optional) Subdirectory of projroot
where are the final .jad/.jar files (default: 'bin')
resdir (optional) Subdirectory of projroot
where are the resource files (default: 'res')
libjar (optional) Fully qualified path of user library jar file(s)
whose classes are inserted (semicolon separated list)
proguardjar (optional) Fully qualified path of the ProGuard jar file
If specified, the classes are optimized/obfuscated
to reduce the jar size and prevent reverse-engineering
url (optional) URL of the MIDlet jar file (value of MIDlet-Jar-URL entry in jad file). If specified, the jar/jad file names are modified accordingly
config (optional) Value of MicroEdition-Configuration entry in jad file
(default: 'CLDC-1.1')
profile (optional) Value of MicroEdition-Profile entry in jad file
(default: 'MIDP-2.0')
devname (optional) Value of the device name when running the emulator
(Xdevice parameter of emulator.exe)
-d (optional) A modeless dialog is shown,
where the midlet package name can be modified
-e (optional) After verifying/packing, the default WTK emulator
is started running the .jad/.jar
-t (optional) Copy files from resource directory into root of jar
-v (optional) Verbose: write debugging information to System.out and
keep the temporary directory


Example for a MIDlet in package ch.aplu using separator \:

java -jar MidPak.jar -e -i=c:\jars\gidlet.jar -o=c:\jars\proguard.jar ch.aplu.Game c:\myfiles\GameMidlet c:\wtk25 c:\wtk25\lib\midpak

will assume:

- Main class (overriding MIDlet): in c:\myfiles\GameMidlet\src\ch\aplu
- Compiled classes in c:\myfiles\GameMidlet\classes\ch\aplu
- GameMidlet.jar, GameMidlet.jad in c:\myfiles\GameMidlet\bin
- Project name: GameMidlet
- Root directory of Wireless Toolkit: c:\wtk25
- Directory with jars needed for preverification in c:\wtk25\lib\midpak
- Files to include will be extracted from c:\jars\gidlet.jar
- Optimization with ProGuard using c:\jars\progard.jar
- Temporary directory c:\myfiles\GameMidlet\tmpclasses is used

A picture is worth a thousand words:



The parameter url is useful when creating MIDlets deployed on a Http server. E.g. if the deployment file are named Game.jar and Game.jad resides at, specify:


In this case the WTK emulator (option -e) cannot be used anymore.