The SDK I used have a date of December 5, 2002 on the download page. If you find any newer SDK, this howto may not apply to it.
The goal of this mini-HOWTO is to help beginner P800 programmes set up the free SDK for Personal Java development. I noticed that a lot of people cannot get it to work, so this is just a short list of what to do. I'm not going to teach you how to program Java, just the setup.
I applogize in advance for the language. I'm not a native English speaker, and it's almost 4am, so as along as you understand what I write, I don't care. ;-)
DISCLAIMER: I spent several hours setting this up. It was mostly trial and error. The following description is what I remember doing. It may not be complete. I will (of course) try to make it as complete as it can be, but I make no promisses that this will work for you.
Download the SDK from here.
If the link doesn't work, go to www.symbian.com.
then click on Developer, then SDKs and you should find a link. The are some
files to download. The readme, the "Symbian P800 Emulator", and the
SDK in 6 files. A total of 8 files. Unpack the SDK using winzip8.1 (www.winzip.com)
(You have to be registered developer on Ericsson's site to download the SDK,
but this is free and worth it.)
Install the SDK by executing SETUP.EXE. Some strange things will happen at this point. The installation program will first install jdk and then launch another installation program. That's ok. When asked what to install, select EVERYTHING. Even if you don't own CodeWarrior and don't plan developing in C++, you still have to install the C++ part, otherwise you'll get problems later. I suggest you install the SDK in the sugested directory: c:\Symbian.
After that unzip the files from the "Symbian P800 emulator" and copy them to C:\Symbian\UIQ_70\epoc32\data replacing old files. This will make the emulator look and work like the P800.
Also, to get everyting working, you should install JDK 1.1.8 from SUN (java.sun.com). Some people say that JDK 1.4 works, with some switches, but the 1.1.8 is the recomended version.
Restart windows if needed.
There are some things that need to be set up. The documentation is poor (in my opinion) but I got it working. I don't know if my setup is the best possible (probably not), but it works, and I'm happy with that.
I like to set up the directories the way the examples are set up. I have all
my development apps in C:\Symbian\UIQ_70\erj\AppName
For every project I create the following directry structure:
MyAppName +--code (to store the .class files and everyting needed by the emulator to run the app) +--source (the .java files) +--install (the contents of the SIS-package, ie. the .jar, .app, etc.) +--sis-package (the actuall packed .SIS file will be created here)
I won't explain much here. I use this script (build.bat) to compile an application (it's mostly copied from one of the examples). You have to change the name of the app. The script also makes a .jar file and puts it in the "install" directory for later deploying to phone.
All the scripts reside directly in the MyAppName directory.
------------------------------------------------- @echo off if "%epocroot%" == "" goto noepocroot set appname=MyAppName set localclasspath=%epocroot%epoc32\java\lib\classes.zip;%epocroot%erj\classes;%epocroot%erj\ext\qawt.jar;%epocroot%erj\ext\util.jar;%epocroot%epoc32\java\ext\javaphone.jar cd %epocroot%erj\%appname%\ if not exist %epocroot%erj\%appname%\code\ mkdir %epocroot%erj\%appname%\code javac -classpath %localclasspath% -d code source\*.java if errorlevel 1 goto failed cd code jar -cf ..\install\%appname%.jar *.class cd .. echo Successfully compiled %appname% goto exit :failed echo Failed to compile %appname% goto exit :noepocroot echo The environment variable 'epocroot' has not been set. echo Ensure that it is set to where you installed the UIQ SDK. echo E.g. C:\Symbian\UIQ_70\ goto exit :exit -------------------------------------------
To run the emulator, you have to setup two virtual drives. j: for emulator java runtime, and t: to point at your apps. The reasonsto ClassNotFound exceptions is most often that you fail to define the drives correctly. I use this script (apprun.bat) to set it all up and run with one command. You have to change the name of the application and main class (marked in red) to match your application.
----------------------------------- @echo off setlocal set epocroot=C:\Symbian\UIQ_70\ set _epoc_drive_j=%epocroot%epoc32\java\ set _epoc_drive_t=%epocroot%erj\ %epocroot%epoc32\release\winscw\udeb\pjava_g -Dcom.symbian.appName=JWorm -cd t:\JWorm\code JWorm wait endlocal -----------------------------------
This one was really a pain in the (censored) to get working. I'm probably missing
something here, but anyway, I eventually got it working.
The result of this stage is a .SIS file that should install on the phone. The
.SIS should contain all your .class files (preferably in a .jar) all graphics
sounds and stuff. You should be able to squize the graphics files into the .jar
and use classes from java.utils.zip to read them. I didn't figure this out yet.
In addition to your code you need some extra files that are needed by Symbian
to make your application appear and work in the phone.
Start AIF Builder by typing "AIFBuilder" in the command prompt. I always work with the command prompt, writing small .bat files to get things working, this is the fastest way I believe (If you don't want to pay for your tools of course). The AIF Builder (GUI) should now start (if we set up everyting correctly before).
The AIF Builder hace 3 tabs. On the first tab (Application), change "Application
language" to "Java", "Application name" to the name
of your application, "Application UID" to a valid UID (you have to
email to Symbian to get some valid UIDs. Don't ever release anything publicly
without a valid UID!). For testing purposes you can use a number in the range
0x01000000 to 0x0fffffff. 0x01000042 is a valid test UID. It's important that
every application in your phone has a different UID. Otherwise things can get
bad. Then change the "Java Command Line text" to "-cp MyApp.jar
MyApp" where MyApp.jar is the name of your jar file, and MyApp is the name
of the class containing your main() function. If you don't have a .jar file,
then this should be "MyApp" only (ie. no -cp....)
On the second tab(UI variants), make sure that UIQ is selected. Then position the cusor in the "Name of MBM" textbox and click "Create" below. Here is where you draw your icon. You'll probably figure this out, but the image on the left is the actual icon, the image on the right i a mask. Everything that is white on the mask gets background color. When you're done, just save and select "File->Exit". You will end up back in AIF Builder. In "Location to generate files" enter "C:\Symbian\UIQ_70\erj\MyApp\install\" (if you followed my directory structure). In "Output directory for temporary files" enter "C:\temp" (or whatever location where you keep your temporary files).
The third tab (Captions) is optional. Here you can write the name of your Application in different laguages. If you don't do it, the "Application name" from the first tab will be used for all languages.
When you're finished, save your work and click the "Generate"-button. If everything went OK, you should now have 3 files .app, .txt and .aif. (and a temp file .rss) These files now reside in the install directory, together with the .jar and the rest of your files that should go into the .SIS-package.
There must be a tool for this somewhere, I just didn't find it yet. Don't worry, it can be done with Notepad. ;-)
You have to create a .pkg file. Let's call it myApp.pkg. The contents of the file shold look like this.
; Installation header
#{"MyApp"},(0x01000042),1,0,0,TYPE=SA
;
(0x101F80BE), 1, 0, 0, {"SonyEricssonP80xPlatformProductID"}
;
; Files
"\Symbian\UIQ_70\erj\MyApp\install\MyApp.aif"-"!:\System\Apps\MyApp\MyApp.aif"
"\Symbian\UIQ_70\erj\MyApp\install\MyApp.app"-"!:\System\Apps\MyApp\MyApp.app"
"\Symbian\UIQ_70\erj\MyApp\install\MyApp.jar"-"!:\System\Apps\MyApp\MyApp.jar"
"\Symbian\UIQ_70\erj\MyApp\install\MyApp.txt"-"!:\System\Apps\MyApp\MyApp.txt"
;
; Gfx
"\Symbian\UIQ_70\erj\MyApp\install\myPic.gif"-"!:\System\Apps\MyApp\myPic.gif"
I'll explain... Every line beginnig with a ; is a comment.
The #{"MyApp"},(0x01000042),1,0,0,TYPE=SA
line says the name of the Application is MyApp, the UID is 0x01000042 (the same
as in the AIFBuilder) and the version of the application is 1.0.0. The type
is Application (there could be other types for system liberies and stuff). The
format of the .pkg file is pretty well documented in the SDK docs.
The line (0x101F80BE), 1, 0, 0, {"SonyEricssonP80xPlatformProductID"}
is required, otherwise the SIS packege won't install on the phone.
The other lines is a list of files that should go into the SIS. This should
be the contents of the install directory (i.e. your application and all files
it needs and the 3 files generated by AIFBuilder. The format of the line is,
as shown above, the full path to the file on your system (with no drive letter)
then a - and then the location of the file on the P800. The files should always
be installed into "!:\System\Apps\AppName". The ! meaning that the
user can select the drive (internal or memory stick) where the application should
be installed.
Now it's time to generate the .SIS-package (at last). Just write makesis MyApp.pkg and that's it. Here is the bat file (deploy.bat) that I use to build the package.
@echo off set epocroot=\Symbian\UIQ_70\ makesis MyApp.pkg move MyApp.SIS sis-package
The steps described here should work, but one never knows.
All .bat files should be placed directly in the MyAppName directory of the
directory tree. The .pkg file should also be put there. The source files for
AIFBuilder (.aifb and .mbm) can reside wherever you want them.
Remember you have to install ALL of the SDK. If you don't install the C++ part,
the aifbuilder will fail generating it's files.
For some people (myself included) the emulator crashed at startup. In my case REMOVING BlueTooth device from my computer "solved" the problem.
Good luck.