I think the best way to learn to use a tool is learn by examples. So here we go first I'll explain how to
create your environment and then we'll go through a code tour for a Hello World application.
PREREQUISITES PAGE:
Create your own environment
1) Prerequisites: download and install
1.1)JDK 1.6+
1.2)WTK 2.5.2 or newer,
1.3)ant
1.4)antenna
1.5)Proguard
on your computer
2)If you don't have a Subversion client yet, install TortoiseSVN if you're using Windows, or
SmartSVN if you're using any other platform. There are other SVN clients
as well, just install the one of your preference or google "SVN client" to find more
NOTE: if you are unfamiliar to SVN or to any kind of versioning system, I strongly recommend that you read
the SVN book at http://svnbook.red-bean.com/ Apart from being a must read, it is quite an interesting reading for anyone involved in development.
3) Checkout the trunk SVN repository from http://svn.assembla.com/svn/prosciutto/trunk
4) under the /client folder in your newly created working copy of the repository, find and edit the file named build.properties
and edit these lines according to your installation:
Windows (example):
WTK-home=C:\\WTK2.5.2
ant-home=c:\\ant
Linux (example):
WTK-home=/usr/local/WTK2.5.2
ant-home=/usr/local/ant
5) (optional) Download the J2ME Polish XML device database. You'll need this for Antenna to run to its full power.
As of the time of writing this tutorial, the DB can be found at http://devices.j2mepolish.org/interactivedb/searchdevices.faces
or by going to http://devices.j2mepolish.org/, then click at the link "Browse the device database" on your left, then look
at the squared section at the upper right corner, and click on "download current stable devices.xml file".
5.1) unzip devices.zip and place the devices.xml, groups.xml and vendors.xml files somewhere in your hard drive, preferrably in a folder at the same level as your trunk working copy of Prosciutto/ZAMAE as you downloaded in step 3. For the sake of this tutorial, I placed the files under D:\proyectos\devices
5.2) open and edit the build.xml file under/client/package folder of your SVN working copy. Replace all occurences of the value of "devicedbpath" to the newly created folder where you placed the device database, i.e. D:\proyectos\devices
6) Now let's build ZAMAE. Zamae has many different versions, ranging from a basic one to a fully featured one that includes the Persistence
Framework, compression and DES encryption.
These are the different ant targets that build the different versions:
midp10cldc10: very basic version (MIDP 1.0, CLDC 1.0)
midp20cldc10: basic version
midp20cldc10_connectionless: basic version, unable to connect to the outside world through HTTP (but saves some space though). You'd use this for standalone applications.
midp20cldc10_persistence: basic version with persistence framework (uses RMS)
midp20cldc10_persistence_zlib: basic version with persistence framework (uses RMS) with compression (only for handsets with enough RAM)
midp20cldc10_encrypt: this version encrypts everything sent to the server, with default encryption
midp20cldc10_encrypt_AES: same as aboce, with AES encryption only
midp20cldc10_encrypt_DES: same as aboce, with DES encryption only
all_features: this is the full featured one (persistence, compression, encryption)
If you want to build all versions (which is recommended anyways), just get into the /trunk/client/package folder and
type "ant". This will automatically run the default ant target as defined in the local folder build.xml file, and will end up
creating all the possible jar files for each different version of ZAMAE.
For the sake of this tutorial, we are only going to build the basic one: "build_midp20cldc10".
just type ant build_midp20cldc10 and hit Enter.
The process should end in less than 10 seconds, and you'll have a bin folder created, which will contain the file "zamae-midp20cldc10.jar".
That's it! at least as per what it takes to create the engine.
7) Now let's compile the HelloProsciutto application. Just run the following ant target in your \demos\helloworld folder:
ant build_ONLY_PHONETEST4
You will end up having a .jad/.jar pair in the folder \demos\helloworld\bin\english\Nokia\6255i. Just double click on HelloProsciutto.jad to see your application
running, or execute it in your preferred emulator. (NOTE: this is just a test on some preferred phone attributes using Nokia 6255i but it should
run anywhere without any modifications at all).
I strongly encourage you to play around with the files in the \demos\helloworld\models folder, note that the demo application is always including
"models.xml" file in the resulting jar file when you hit the build_ONLY_PHONETEST4 ant target, so you might want to take a look at this file
and rename the other files to "models.xml" each time to see what happens. Just modify this file and compile to see what has changed.
That's it!
For a quick guide to XML definition attributes and possible values, check this Start guide.