Main Page | Recent changes | Edit this page | Page history

Printable version | Disclaimers

208.70.31.205 (Talk)
Log in | Help
 

Zaurus Java FAQ

From OESF

Table of contents

Main

Where did this Java FAQ come from?

It has been found at http://adorphuye.com/zaurus/java/faq.jsp

The original author of this FAQ is Steph Meslin-Weber, mailto:twiun@adorphuye.com. A fair number of people have also contributed in various ways by providing information, links or criticism:

Java Extensions

What extensions?

When Java 1.1 was released, additional extensions (Swing, Collections) were also released to make up for gaps in the api coverage.

As each new Java version ships, these extensions get included into the core api. Currently on the Zaurus, only PersonalJava 1.2 - equivalent to Java 1.1 - is available, and so we start looking at the api extensions for extra functionality

Can I use Secure Sockets on the Zaurus?

From Steve Weyer:

(non JSSE things snipped)

regarding extensions, Sun's JSSE (Java Secure Socket Extensions) 1.0.2 works fine with PJ on Z. this allows https: connections among other things. I've used with my CrozzWord app for secure login to NYTimes subscription area. downside: it's ~420K

Can I use SVG on the Zaurus?

Here are a few screenshots to give you an idea of the demo:

Image:Tinyline01.png Image:Tinyline02.png Image:Tinyline03.png Image:Tinyline04.png Image:Tinyline05.png Image:Tinyline06.png Image:Tinyline07.png Image:Tinyline08.png Image:Tinyline09.png Image:Tinyline10.png Image:Tinyline11.png Image:Tinyline12.png


Can I use Swing?

Short answer: No.

Long answer: Swing can be used on the Zaurus with the Jeode VM but you must use the unbundled Swing distribution1 and you must edit SwingUtilities.java in that distribution. This is due to a Swing bug2 that will not be fixed by Sun. Also note that certain parts of Swing use native code which is currently unavailable for the ARM platform; this means parts of Swing will not work.

Note: Because of the Sun License, I cannot redistribute modified Swing sources or jar files.

Instructions taken from the bugparade report2:

1. Extract the src.zip (from the swing-1.1.1fcs distribution). 2. in javax/swing you'll find the SwingUtilities.java file. 3. Open it your favorite editor 4. Comment out line 677:

 Method m = Class.class.getMethod ("getProtectionDomain", null);

5. Insert the line

 Method m = Class.class.getMethod ("getPackage", null);

just after the old one.

6. Save and compile (javac -classpath swingall.jar:. javax/swing/SwingUtilities.java)

7. Backup the Swingall.jar archive in the root of the exstracted src.zip (ie the same level of the javax and com dirs).

8. Jarize it (jar uvf swingall.jar javax/swing/SwingUtilities.class)

Image:Zaurus_swing.png

11Unbundled JFC 1.1 with Swing 1.1.1 (http://java.sun.com/products/jfc/download.archive.html)
2Bug Id #4309057 (http://developer.java.sun.com/developer/bugParade/bugs/4309057.html)

Can I use JDBC?

More info as it comes in!

Miscellaneous

What Classes can I use?

(It is apparently still possible to use JNI, obviously, use at your own discretion)

NOTE: This excludes all the J2SE Classes (Swing, JMF, JAI, etc)


What graphic file formats does Jeode support?

GIFJPGPNG
PalettedImage:Ticked.gifImage:Unticked.gifImage:Unticked.gif
TrueColourImage:Unticked.gifImage:Ticked.gifImage:Ticked.gif
LosslessImage:Ticked.gifImage:Unticked.gifImage:Unticked.gif
TransparencyImage:Ticked.gifImage:Unticked.gifImage:Ticked.gif

Can I develop ON the Zaurus?

The build-in keyboard makes this an ideal use for the Zaurus, although you'd probably be faster on a desktop machine. The keyboard on the Zaurus is not, in my opinion, intended for writing novels ;-)

Because of the limited memory footprint of the Zaurus you shouldn't expect to be able to run, say, NetBeans, but with an editor and a compiler you should be set to go!

So far, compilers that run on the Zaurus include Kopi and Jikes.

Editors can include:

Additionally, Pierre MÈtras has written a HOWTO based on MinIDE+Kopi at http://www.alterna.tv/jsearch/ (http://www.alterna.tv/jsearch/). As this HOWTO is in French, I'm in the process of translating it into English - should be finished in a few days. (Current translation at here (http://adorphuye.com/~twiun/D%e9veloppement%20Java%20sur%20le%20Sharp%20Zaurus.html))


Can I play sounds using Java?

This is now changing, with thanks to didge for the information:

I have been able to use the Java Media Frameworks to play sounds on my SL5500. Here are instructions:

Using JMF2.1.1b (the cross-platform version) to play .wav files on the Zaurus can be achieved by doing the following:

Create your own custom.jar (using JMFCustomizer w/ jdk1.4). Check the following items:

Make sure that custom.jar and jmf.properties are located in your classpath. Additionally, you will need to start Jeode with the following arguments:

The first increase the memory for jeode. The second ensures that the JMF custom.jar is loaded correctly. #SYSTEM# is a standin for Jeode's class libraries and the s ensure that the shell does not consume the #s before evm gets the argument.


Any caveats or things I should watch out for?


What class libraries are available for the Zaurus?

Lightweight AWT GUI toolkits (or why be stuck with AWT?)

XML Parsers (or why make do with properties files?)

Databases (or why settle for flat files?)

Cryptography (or why keep things simple?)


Problems with java.util.Date & Co.

Posted: April 21 2002,19:21

It appears there maybe a problem accessing the time on the device. I've tried using both the Date() and the GregorianCalendar() classes.

This problem appears to be dependent on which city you select. For example, if you select Chicago or Los Angeles, the time appears to return correctly. However, if you select a city such as Kansas City, Oslo, Hong Kong, the time returned is the GMT time instead of the local time. In other words, the GMT time and local time are the same. When you query the time zone offset, it is 0.

I should note that the time always appears correctly in the sytem tray on the device.

Any ideas?

Posted: April 25 2002,03:19

I have been exchanging emails with Sharp (Japan). They have located the problem in the Insignia code. They are waiting on a fix or work around from Insignia.

In short, Java supports a much smaller list of cities than the Zaurus. When a city isn't found, it defaults to GMT for the time zone. Oooops!

I will post an update when I get a final response from Sharp and Insignia.

Posted: May 11 2002,23:58

I have heard back from Sharp regarding this problem. Insignia has stated they only support the following cities: Africa/Casablanca Europe/Paris Africa/Cairo Asia/Riyadh Asia/Tehran Asia/Yerevan Asia/Karachi Asia/Calcutta Asia/Dacca Asia/Bangkok Asia/Shanghai Asia/Tokyo Australia/Darwin Australia/Sydney Pacific/Guadalcanal Pacific/Fiji Pacific/Apia Pacific/Honolulu America/Anchorage America/Los_Angeles America/Denver America/Chicago America/New_York America/Caracas America/St_Johns America/Buenos_Aires America/Sao_Paulo Atlantic/Cape_Verde America/Costa_Rica Asia/Beirut Africa/Johannesburg Asia/Jerusalem Europe/Moscow Asia/Vladivostok Australia/Hobart

Sharp has told me that Insignia does not plan to fix it. Even though they are under contract to Sharp, Sharp is not going to press Insignia to fix it.

If you would like this fixed, I would recommend that email is sent to both Sharp and Insignia. The developer support email for Sharp is kpda_pt@pda.nara.sharp.co.jp. I could not find a support email for Insignia.

Hopefully, if enough people complain, they will get this problem fixed.

I agree that this is an issue that should be resolved. The Zaurus is after all an international device.

Can I learn Java on the Zaurus?

One thing I'd like to make clear is that I don't think any PDA is suitable for learning Java (and quite likely other languages).

You need a flexible environment and be able to debug, type and browse documentation easily and fast. You won't be able to do all that on a PDA.

The Java tutorial at Sun isn't a 400-page book, it has valid examples for you to work with and very good explanations, as well as instructions on getting Java working on the desktop OS of your choice: http://java.sun.com/docs/books/tutorial/index.html (http://java.sun.com/docs/books/tutorial/index.html)

Java on the Zaurus is still pretty much stuck at version 1.1, this means that once you've learnt the Java syntax, get hold of a 1.1 Java sdk and use this for development on your desktop. It's of course possible to use later versions for this, but doing so may lead to more headaches further on.

I, like most others, do my Java development on the desktop in any case - the compiled code will (should) run without modification on the Zaurus if you work within the Java 1.1 specs. So there isn't a dire need for tools for use on the Zaurus. This is not to say there aren't any - there are quite a few: 2 compilers, 2 virtual machines (2 more on the way), 3 IDEs and countless class libraries that work perfectly fine on the small form factor.

So with regards to development tools for use on the Z, I'd say hold on, learn Java first :-)

I heartily recommend the #java channel on irc.freenode.net for help with learning Java, make sure you've read the Java tutorial first though - you'll get flak if you don't ;-)

Packaging

How do I arrange sources/classes prior to packaging?

Compiling your classes should be done with a pre-Java 1.4 sdk, or using the -target 1.1 command line argument for the compiler to specify that compiled classes should follow the Java 1.1 class file structure (and version).

Your compiled classes should be contained in one or more jar files to save on space and filesystem clutter.


How do I package using the .ipk format?

CONTROL

_           <-- package control files

opt

_QtPalmtop
  |_bin     <-- application start script
  |_apps
  |  |_Applications <-- application .desktop entry2
  |  |_Games
  |   _Settings
  |_java
  |  _myapp <-- application jar (+html file for applets)
  |_etc
  |  _myapp <-- application configuration files
  |_pics    <-- application icon
  |  _myapp <-- application image resources
   _help
     _en    <-- application help files (english)

Please read this document to learn how to make an .ipk file package.

The java application start script cannot be passed command line arguments from the .desktop file and so must be self contained. It can be conceivably called anything you want. The current convention is to use the run prefix, eg: runSomeCommand

IMPORTANT Your application does not have be installed in RAM, it could be installed on CF or SD media - this means that paths to resources must not be hard-coded. Thankfully, the Qtopia environment provides a means to find out where installation took place so that we can find our resources.

Your application image should be a 32x32 png file. Although you are free to name it anything, try to use a name which will associate it with your application. Qtopia will resize it as necessary for the taskbar.

Application configuration files are usually stored in a subdirectory of the etc directory such as etc/myapp.

Example .desktop file myapp.desktop

 [Desktop Entry]
 Comment=This is MY program
 Exec=runmyapp
 Icon=myappicon
 Type=Application
 Name=MyApplication


Example start script runmyapp

 #!/bin/sh
 #
 # Change to the java directory where we're installed
 cd ${PKG_ROOT}/opt/QtPalmtop/java
 
 #
 # Populate classpath with our application jar
 CLASSPATH=somejar.jar
 
 #
 # Launch the virtual machine (using the -Xappname argument so that we appear
 # on the tasklist - see Qtopia Integration section)
 evm -cp $CLASSPATH -XappName=runmyapp mainClass

if launching an applet, substitute the last command with:

 $QPEDIR/bin/evm -appletviewer myHtmlpage.html


Qtopia Integration

How well is Java integrated into Qtopia?

Can I use the full screen area?


How do I get the qtopiainfobutton.gif button to show?

To have the button show up on your application titlebar, all you need do is name your main html file the same name as your application, so with an application named runmyapp your main html file would be called runmyapp.html.

The reason for this naming convention is that when your script calls the virtual machine, the -Xappname argument is used with your application name as the parameter, this name is then used for the taskbar icon and... you guessed it, the main helpfile.

This html file (and all the others you need) should be placed in the

/opt/QtPalmtop/help/en/html

directory, replacing en with any other language code as necessary.

If your html pages require images, you should link to them using relative URLs. You can place your images in subdirectories, as long as the url is relative.

Can I run my application maximized?

Note that the application can unfortunately still be dragged and moved! Using a Window and sizing to the size of the screen is not a solution as it is not possible to programmatically position the Window at 0,0 in the Jeode VM. The Jeode VM will shift your Window down by the height of a titlebar even if none is present.

Why doesn't my application have a taskbar icon?

 evm -XappName=myAppName

When called from a script, as is necessary for Java applications, the following shorthand can be used:

 #!/bin/sh
 evm -XappName=$0

Where the $0 refers to the zeroth commandline argument, namely your script name.

User Interfaces

What should I consider when making a GUI for the Zaurus?

The lack of a mouse means that you will get no MouseEntered or MouseExited events and therefore no Tooltips or rollover effects.

The small screen size is perhaps the more important factor when designing an application for the Zaurus. Information that could have fitted on one screen on a normal sized screen now has to be distributed amongst several forms. You can achieve this using CardLayouts or TabbedPanes, bearing in mind that with each additional component you add will increase your memory footprint. </ul>


Any tips for creating my application's icon?

The insets usually contain the drop-shadow in the south-eastern direction. The drop-shadow is a black underlay with an alpha gradient - easily obtained in Gimp.

How can I make use of the qtopiaclosebutton.gif button in my application?

Since memory is expensive, creating a listener to close a frame is wasteful. Instead, I would suggest creating a subclass of Frame with the desired behavior:

 public class MyFrame extends Frame
 {
     public MyFrame()
     {
         enableEvents(AWTEvent.WINDOW_EVENT_MASK);
     }
 
     protected void processWindowEvent(WindowEvent e)
     {
         if(e.getID() == WindowEvent.WINDOW_CLOSING)
             System.exit(0);
     }
 }     

The above raises the point that too often listeners are used when subclassing and using processEvent would eliminate extraneous object creation, not to mention would perform faster as well. Note that using a listener not only means you have to have a the listener, but AWT use the AWTEventMulticaster which incurs additional overhead. But of course, this is an optimization for where it's appropriate.

Usual (desktop) way of doing things:

Frame myFrame = new Frame("SomeTitle");

 myFrame.addWindowListener(new WindowAdapter()
 {
     public void windowClosing(WindowEvent e)
     {
         System.exit(0);
     }
 });


What fonts can I use on the Zaurus?

Additionally, Jeode on the Zaurus has broken generic font support so that font names must be explicitly specified. For instance, using the smoothtimes font preinstalled on the Zaurus, one would create a font thusly:

 Font f = new Font("smoothtimes", Font.PLAIN, 10);

Fonts that come preinstalled on the Zaurus are:

You can also create your own fonts, or convert TTF fonts, see the Font Issues faq entry for more information.

(Font Issues) How can I use fonts on the Zaurus when using Jeode?

 Font f = new Font("fixed", Font.PLAIN, 10);

TrueType font support isn't compiled into Qtopia for the Zaurus so you have to use what's already there in /opt/QtPalmtop/lib/fonts/*.qpf, or you have to provide your own by using the qpf build tools present in the Qtopia source distribution (Trolltech, qpf fonts defined).

Using the above for custom fonts, you would create your qpf font, place it in the /opt/QtPalmtop/lib/fonts directory on the Zaurus and use the following code:

// Assuming the font is named kanjifont_100_50_t10.qpf

 Font f = new Font("kanjifont", Font.PLAIN, 10);

How can I use the GridBagLayout on the Zaurus?

 GridBagConstraints gbc = new GridBagConstraints();
 gbc.gridx=1;
 gbc.gridy=10;
 ... //access private fields directly
 SomeContainer.add(SomeButton,gbc);
 
 gbc.gridx++;
 SomeContainer.add(SomeLabel,gbc);

The GridBagLayout makes a copy of the constraints passed to it via the add method and uses that to layout the button/label or Component. Because a copy is used internally by the layout, you're free to keep on modifying your version for subsequent layout additions.

Please note that GridBagLayout uses floating-point math operations heavily1, is a complex layout and as such will be less performant than a simpler, integer-based one.

Virtual Machines

What virtual machines exist for the Zaurus?

Is J2ME supported on the Zaurus?

Note that this software is for evaluation only; it is not supported and cannot be used in a product. This release is for you if you are interested in the leading edge of Personal Profile technology and would like to see a high-performance, optimized implementation.


Is J2SE available for the Zaurus?

Blackdown also seems to have an ARM port of its Java 1.3.0 virtual machine present on its mirrors. Note that this vm will most likely have the native peers working under X, not Qtopia.


Installation of Java on unsupported Zaurii

Installation of Java on the SL-C3000/C1000

Currently, it is not officially supported to install Java on the SL-C3000. However, some enterprising soul found a way to do it, but this includes getting your hands on a SL-C860. The whole process is not really difficult if one follows the instructions posted here (http://augustin.vidovic.org/pages/java_on_zaurus_sl_c3000/index.html).

Followed these instructions to also install Java on an SL-C1000, worked like a charm.

Retrieved from "http://www.oesf.org/index.php?title=Zaurus_Java_FAQ"

This page has been accessed 9295 times. This page was last modified 04:45, 18 May 2007. Content is available under GNU Free Documentation License 1.2.


[Main Page]
Main Page
Recent changes
Random page
Current events

Edit this page
Discuss this page
Page history
What links here
Related changes

Special pages
Bug reports