Hello World App

This tutorial will help you create the infamous Hello World app in the version of a stand-alone GUI app.

wpe11.jpg (5503 bytes)

I have attached a copy of the java and the class file.

HelloWorldApp.java

HelloWorldApp.class

To begin, you will need to install the latest JDK. You can find the latest version at java.sun.com. (I am using JDK 1.3.1_03.)

After install is complete reboot your system.

Create a folder in your c:\jdk1.3.1_03 folder called source.  (This is where you will keep all your .java files)

Create a folder in your c:\jdk1.3.1_03 folder called classes.  (This is where you will keep all your compiles .class files)

Open notepad.

Enter the following

import java.awt.*;
import java.awt.event.*;
import java.applet.*;


public class HelloWorldApp extends Frame implements
ActionListener {
private Image im ;

Button button = new Button("Exit");
Panel panel = new Panel();
Label label = new Label("Hello World!");

public void start(String args) {
setLayout(new FlowLayout(FlowLayout.CENTER));
panel.setLayout(new FlowLayout(FlowLayout.CENTER,2,2));
panel.add(button);
panel.add(label);
add("North", panel);

button.addActionListener(this);

validate();
}
public void actionPerformed(ActionEvent event) {

String str = event.getActionCommand();

if (str == "Exit")

System.exit(0);

}

public static void main (String args[]){
HelloWorldApp testApp = new HelloWorldApp();
testApp.start("a");
testApp.setSize(240, 280);
testApp.validate();
testApp.show();
}
}

Save this file as HelloWorldApp.java in the c:\jdk1.3.1_03\source folder.  (Make sure it didn't get called HelloWorldApp.java.txt)

Open a command prompt and type the following lines hitting enter after each line.

path = c:\jdk1.3.1_03\bin

cd\

cd jdk1.3.1_03\source

javac -d c:\jdk1.3.1_03\classes HelloWorldApp.java

Hit Enter.

wpeE.jpg (21751 bytes)

If compiling is successfull the command line will return without any errors like above.

Next, type the following line.

cd ..

cd classes

java HelloWorldApp

wpeF.jpg (22268 bytes)

If successfull you will see a new window open like below.

wpe10.jpg (5506 bytes)

 

Transferring the Hello World App to the Zaurus

Next, using windows explorer, open the c:\jdk1.3.1_03\classes folder and copy the file into your documents view of you Qtopia desktop for upload to the Sharp.  Click the Sync All button.

hello_5.jpg (16292 bytes)

If prompted for a location select Internal Storage.  (You will only be prompted if you have added a CF, SD, or MMC card.)

hello_6.jpg (8383 bytes)

On the Zaurus open a Termal shell on the Zaurus.

hello_7.jpg (20480 bytes)

Enter the following.

cd Documents/application/octet-stream

evm HelloWorldApp

Then hit the return key hello_8.jpg (825 bytes)

If successful you should see the following.

wpe11.jpg (5503 bytes)

(This isn't an actual screen print from the Zaurus, but it will be similar.)