Programming for PDA - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Programming for PDA

Description:

The Solution: Use IBM's J9 or NSICOM's CrEme JVM ... CrEme Developed by www.nsicom.com. 30 Day free trial available. Execution Speed Fast ... – PowerPoint PPT presentation

Number of Views:128
Avg rating:3.0/5.0
Slides: 34
Provided by: admi1165
Category:

less

Transcript and Presenter's Notes

Title: Programming for PDA


1
Programming for PDA
  • Personal Digital Assistant

2
The Hardware
  • The Dell Axim X51v will be the deployment system
    of choice.
  • Processor Intel PXA270
  • Processor Speed 624 Mhz
  • RAM Size 64 MB
  • ROM Size 256 MB
  • Connectivity WiFi Bluetooth
  • Display 3.7 TFT 640 x 480
  • Graphics System 2700G 16MB
  • OS Window Mobile 5.0

3
The Hardware - Essentials
  • USB Cable and Docking Station for Synchronisation
    with Desktop System
  • Bluetooth Enable Keyboard for ease of data input

4
The Software Essentials - ActiveSync
  • This typically comes with the PDA but can also be
    downloaded from Microsoft
  • It allows for the synchronisation of files and
    the viewing of the mobile devices file system
  • When transferring files it is essential to turn
    off File Conversion when copying files
  • See Tools -gt Advanced Tools -gt Edit File
    Conversion Settings

5
Screen Capture
  • The ability to carryout screen captures is
    especially useful when testing programs
  • Many applications are available for this purpose
  • Some are downloaded and executed directly on the
    PDA
  • Others are installed on your Development Desktop
    System and use ActiveSync to retrieve the Screen
    Capture

6
Screen Capture - Example
  • HauteCapture 1.1 (Shareware Application)
  • Available from http//www.windowsmobiletoday.com/
    software/pocketpc/HauteCapture-2006-1-17-ce-pocket
    pc.html

7
What VMs are available for PocketPC
  • This is the most popular question and also the
    biggest barrier for deploying Java Applications
    on PocketPC
  • The Solution Use IBMs J9 or NSICOMs CrEme JVM
  • Several others are available but suffer from
    several problems
  • Suns Personal Java Not supported anymore
  • SuperWaba Not fully Java compatible
  • Ewe Not fully Java compatible
  • Jeode on Sale to OEMs only (HP PDAs for
    example)
  • Mysaifu JVM Version 0.2.2 March 3rd 2006

8
Virtual Machines
  • Jeode Developed by www.esmertec.com
  • It is free with some Compaq iPAQ devices
  • Available for Dell PDAs from Handango
  • Execution Speed Fast
  • CrEme Developed by www.nsicom.com
  • 30 Day free trial available
  • Execution Speed Fast
  • IBM WebSphere Studio Developed by IBM
  • Available as a 30 day trial
  • Includes the J9 Virtual Machine
  • Execution Speed - Fast

9
Developing Applications with J9
  • The following link is to a modified version of
    PlaceLab, It includes the J9 VM and is the
    easiest way to acquire J9.
  • http//www.ece.ucdavis.edu/chuah/classes/EEC173B/
    project/placelab.zip
  • Once downloaded and unzipped it must be copied to
    the root directory of the mobile
  • An unmodified version is available at
    http//www.placelab.org/toolkit/

10
Developing Applications with J9
  • To compile and execute on a Windows Machine a
    platform-specific executable is required
    http//www.placelab.org/toolkit/
  • Unzip this file and place the application folder
    at the root level of your HD
  • Compiling a sample application with J9 will
    result in errors
  • incorrect classpath C\placelab-win32\j9\lib\jclM
    ax\classes.zip
  • incorrect classpath C\placelab-win32\j9\lib\jclM
    ax\locale.zip
  • To resolve this create a directory called jclMax
    in the lib directory and copy the classes.zip and
    locale.zip to the new directory

11
Edit the Path Environment Variable
  • To remove the need for stating c/placelab-win32/j
    9/bin/j9c.exe every time you wish to compile edit
    your path settings so the OS will look in the
    specified directory for applications
  • Right Click My Computer -gt System Properties

12
Compiling
  • C\helloworldgtc/placelab-win32/j9/bin/j9c.exe
    -classpath c/placelab-win32/j9/lib/classes.zip
    helloworld.java
  • C\helloworldgtjavac -classpath c/placelab-win32/j
    9/lib/classes.zip helloworld.java

13
Running the PDA Application from DOS
  • C\helloworldgtc/placelab-win32/j9/bin/j9.exe
    "-Xbootclasspathc/placelab-win32/j9/lib/classes.
    zip" helloworld
  • Hello and Welcome to CS5014 PDA Programming
  • C\helloworldgtc/placelab-win32/j9/bin/j9.exe
    helloworld
  • Hello and Welcome to CS5014 PDA Programming
  • C\helloworldgtjava helloworld
  • Hello and Welcome to CS5014 PDA Programming
  • j9 cp hello.jar helloworld
  • Hello and Welcome to CS5014 PDA Programming

14
Running an Application on the PDA
  • There is no DOS prompt / console on the PDA
  • To execute a program it is necessary to write a
    simple text file (Link file) .lnk
  • The contents of the .lnk file, all appear on a
    single line
  • 255 (The number of characters in the file 255
    Max)
  • -XBootclasspath Location of the essential
    library files
  • -cp /helloworld The directory location of the
    program to execute
  • Helloworld the name of the class file to execute

255\placelab\j9\bin\j9.exe "-Xbootclasspath\plac
elab\j9\lib\classes.zip" -cp "/helloworld"
helloworld
15
Creating JARs - Java ARchive Files
  • JAR files are used to package all the resources
    and classes together into one neat file
  • To create a JAR file use
  • jar cvfm myjar.jar mymanifest.mf .
  • The above example will create a JAR file called
    myjar.jar
  • The file to execute is specified by mymanifest.mf
  • . will include all files in the current
    directory
  • Below is an example of mymanifest.mf
  • The file helloworld will be the file to execute

Manifest-Version 1.0 Main-Class helloworld
16
Java ARchive Options
  • Usage jar ctxuvfm0Mi jar-file
    manifest-file -C dir files ...
  • Options
  • -c create new archive
  • -t list table of contents for archive
  • -x extract named (or all) files from archive
  • -u update existing archive
  • -v generate verbose output on standard
    output
  • -f specify archive file name
  • -m include manifest information from
    specified manifest file
  • -0 store only use no ZIP compression
  • -M do not create a manifest file for the
    entries
  • -i generate index information for the
    specified jar files
  • -C change to the specified directory and
    include the following file
  • If any file is a directory then it is processed
    recursively. The manifest file name and the
    archive file name needs to be specified in the
    same order the 'm' and 'f' flags are specified.
  • Example 1 to archive two class files into an
    archive called classes.jar
  • jar cvf classes.jar Foo.class Bar.class
  • Example 2 use an existing manifest file
    'mymanifest' and archive all the files in the
    foo/ directory into 'classes.jar'
  • jar cvfm classes.jar mymanifest -C foo/

17
J9 It just Java
  • public class HelloCS5014
  • public static void main(String args)
  • System.out.println(Hello CS5014, Welcome to PDA
    Programming!)
  • System.exit(0)
  • Writing Applications is the same as it always has
    been

18
Beyond AWT GUIs - SWT
  • SWT The Standard Widget Toolkit
  • Available from http//www.eclipse.org/swt/
  • It is an open source widget toolkit to provide
    efficient and portable UI facilities
  • Useful Articles on using SWT with PocketPC
  • A small cup of SWT http//www.eclipse.org/articles
    /Article-small-cup-of-swt/pocket-PC.html
  • First PocketPC SWT App http//blogs.bytecode.com.a
    u/glen/2004/11/15/1100468897135.html

19
SWT - Widgets
20
SWT - Widgets
21
SWT - Widgets
22
A Free Alternative Mysaifu JVM
  • Version 0.2.2 released 3rd March 2006
  • Its a JVM which runs on PocketPC (2003)
  • The objective is to produce a JVM that confirms
    to J2SE Footprint quite small (About 10MB
    required)

On PDA
On Windows XP
23
Image Viewer Example
  • import java.awt.
  • import java.awt.event.
  • import java.awt.image.
  • import java.io.
  • public class ImageViewer extends Frame implements
    ActionListener, MouseListener, MouseMotionListener
  • private static final String FILE_OPEN_COMMAND
    "FILE_OPEN_COMMAND"
  • private static final String EXIT_COMMAND
    "EXIT_COMMAND"
  • private Canvas canvas
  • private ScrollPane scrollPane
  • private String filename
  • private int dragStartX, dragStartY, lastX,
    lastY
  • public ImageViewer()
  • super("ImageViewer")
  • this.canvas new Canvas()
  • public void update(Graphics g) paint(g)
  • public Dimension getPreferredSize() return
    getSize()

24
Image Viewer Example
  • public void paint(Graphics g)
  • if (filename ! null)
  • Image img Toolkit.getDefaultToolkit().getImage(
    filename)
  • if (img ! null)
  • g.drawImage(img, 0, 0, this)
  • int width img.getWidth(this)
  • int height img.getHeight(this)
  • if (width ! -1 width ! getWidth())
    setSize(width, getHeight())
  • if (height ! -1 height ! getHeight())
    setSize(getWidth(), height)
  • else
  • final Dialog d new Dialog(ImageViewer.this)
  • d.add(new Label("Faild to load " filename))
  • Button b new Button("OK")
  • b.addActionListener(new ActionListener()
  • public void actionPerformed(ActionEvent e)
  • d.dispose()
  • )
  • d.setModal(true)

25
Image Viewer Example
  • public boolean imageUpdate(Image img, int
    infoflags, int x, int y, int width, int height)
  • if ((infoflags ImageObserver.WIDTH)
    ImageObserver.WIDTH)
  • setSize(width, getWidth())
  • if ((infoflags ImageObserver.HEIGHT)
    ImageObserver.HEIGHT)
  • setSize(getWidth(), height)
  • getParent().doLayout()
  • return super.imageUpdate(img, infoflags, x, y,
    width, height)
  • this.canvas.addMouseListener(this)
  • this.canvas.addMouseMotionListener(this)
  • this.scrollPane new ScrollPane(ScrollPane.SCRO
    LLBARS_AS_NEEDED)
  • this.scrollPane.add(this.canvas)
  • add(this.scrollPane, BorderLayout.CENTER)
  • MenuBar menuBar new MenuBar()
  • Menu menu new Menu("File")

26
Image Viewer Example
  • public void actionPerformed(ActionEvent e)
  • String command e.getActionCommand()
  • if (FILE_OPEN_COMMAND command)
  • FileDialog dialog new FileDialog(this, "Open
    file", FileDialog.LOAD)
  • dialog.setVisible(true)
  • String d dialog.getDirectory()
  • String f dialog.getFile()
  • if (d ! null f ! null)
  • File file new File(d, f)
  • this.filename file.getAbsolutePath()
  • this.canvas.repaint()
  • else if (EXIT_COMMAND command)
  • System.exit(0)

27
Image Viewer Example
  • public void mousePressed(MouseEvent e)
  • this.dragStartX e.getX()
  • this.dragStartY e.getY()
  • this.lastX getX()
  • this.lastY getY()
  • public void mouseReleased(MouseEvent e)
  • public void mouseClicked(MouseEvent e)
  • public void mouseEntered(MouseEvent e)
  • public void mouseExited(MouseEvent e)
  • public void mouseMoved(MouseEvent e)
  • public void mouseDragged(MouseEvent e)
  • if (e.getX() ! this.lastX e.getY() !
    this.lastY)
  • Point p this.scrollPane.getScrollPosition()
  • p.translate(this.dragStartX - e.getX(),
  • this.dragStartY - e.getY())
  • this.scrollPane.setScrollPosition(p)

28
A Free Alternative Ewe
  • Ewe like Superwaba is a free alternative, but
    both are not fully java compatible
  • Available from http//www.ewesoft.com/
  • Latest Version 1.49 (December 2005)
  • Necessary Applications
  • Download and install the Windows Desktop VM
    http//www.ewesoft.com/Downloads/Ewe149-Installer-
    Win32.zip
  • Download the VM for the target device
    http//www.ewesoft.com/Downloads/Ewe149-CAB-Pocket
    PC2003-HighResolution.zip (for 640 x 480 screens)
  • To install on the target device copy the CAB file
    to the device using ActiveSync
  • Clicking on the CAB file will install the VM on
    the PDA

29
A Free Alternative Ewe
  • Download the Ewe SDK (Four separate files)
  • The Class library / Java VM and Ewe Package
    generation application (Jewel) http//www.ewesoft.
    com/Downloads/Ewe149-Developer-SDK.zip
  • The Ewe API (Javadoc) http//www.ewesoft.com/Downl
    oads/Ewe149-Developer-API.zip
  • The Ewe Application Development Guide
    http//www.ewesoft.com/Downloads/Ewe149-Developer-
    Guide.zip
  • Sample Ewe Applications http//www.ewesoft.com/Dow
    nloads/Ewe149-Developer-Samples.zip

30
Ewe Example (Quite Different to Java)
  • package tests
  • import ewe.ui.
  • import ewe.fx. 
  • public class Welcome 
  • public static void main(String args)
  • ewe.sys.Vm.startEwe(args)
  • MessageBox mb new MessageBox(Title Bar
    Text", Experiments with
    Ewe.",MessageBox.MBOK)
  • mb.execute()
  • ewe.sys.Vm.exit(0)
  • The above application will create a Message Box
    displaying some text and an OK Button
  • Note all Ewe applications must begin with
    ewe.sys.Vm.startEwe(args)
  • All applications must end with ewe.sys.Vm.exit(0)

31
Further Information (Books)
32
References
  • Jonathan Knudsen, Wireless Java Developing with
    Java 2, Micro Edition, Apress, 2001.
  • Java Programming for IPAQ 4350,
    http//www.ece.ucdavis.edu/chuah/classes/EEC173B/
    java-on-pda.html
  • Place Lab, Software Downloads, http//www.placelab
    .org/toolkit/
  • Java Support on Pocket PC, http//www.comp.lancs.a
    c.uk/fittond/ppcjava.html
  • Java on PocketPC, the Unofficial FAQ,
    http//www.vikdavid.com/mobile/
  • Reducing the J9 Footprint Required and Optional
    Libraries, http//www-1.ibm.com/support/docview.ws
    s?rs840contextSSSUDGuidswg21112481locen_US
    csutf-8langenen
  • Java Forums JVM on PocketPC 2003 -
    http//forum.java.sun.com/thread.jspa?forumID80h
    ilitefalsestart15threadID466221range15q
  • Java Forums CDC and Personal Profile,
    http//forum.java.sun.com/forum.jspa?forumID80st
    art0
  • Java Forums J2ME Technologies,
    http//forum.java.sun.com/category.jspa?categoryID
    23
  • Suns Programmers Guide, J2ME Personal Profile
    V1.0, http//java.sun.com/j2me/docs/pdf/PP_Program
    mer_Guide.pdf

33
References
  • Using Java on the PocketPC the complete
    tutorial, http//www.pocketpcmag.com/forum//topic.
    asp?TOPIC_ID16612
  • Yahoo Groups, j2me-cdc, http//groups.yahoo.com/gr
    oup/j2me-cdc/
  • Free PDA Books, http//www.j2meolympus.com/freeboo
    ks/freepdabooks.jsp
  • Waba, http//www.wabasoft.com/
  • MIDP Installation Guide For Windows Mobile
    2003 Devices, (J9), http//x.msmobiles.com/portal/
    user_manual/ibm-java.html
  • Using SerialPort with J2ME MIDP WME (aka J9 VM)
    on Palm OS and Windows CE / Pocket PC,
    http//www.serialio.com/support/jspWME_J9_Notes.ht
    m
  • Configuring Java (J9) on a Pocket PC with RMI and
    SWT using CDC Personal Profile some experiences
    and issues, http//awareness.ics.uci.edu/rsilvafi
    /pocketPC/index.html
Write a Comment
User Comments (0)
About PowerShow.com