Quick Start

Table of Contents

  • 1. JailBreak your IPhone/ITouch
  • 2. Install JVM in cydia
  • 3. Set up your development enviroment
  • 4. Code
  • 5. Run/Test in the emulator
  • 6. Package for deployment
  • 7. Deploy and test in real IPhone
  • 8. Modify and Upgrade

1. JailBreak your IPhone/ITouch

It's up to you.It's none of my business.
haha! but be careful,god bless you!
some tips:

  • backup all your data
  • make sure you know all the pre-requirements

some links & keywords:

Spirit is better.

2. Install JVM in cydia

start cydia

in java section

install all the packages in java section
if you are in China,you may encountered so-called GFW...
you can use a proxy or download and install the deb packages manually

install openssh,this is a must
so you can ssh to your iphone and transfer files

this is optional

3. Set up your development enviroment

first,download the binary here
it contains two jars: iswing.jar and emulator.jar
add them in the classpath,it is so simple.

4. Code

sample desktop hello world program:
------------------

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class HelloWorldApp extends JFrame implements ActionListener {

    private JLabel label;

    public HelloWorldApp() {
        this.setLayout(null);

        JButton button=new JButton("Click Me");
        label=new JLabel();
        this.add(button);
        this.add(label);
        button.addActionListener(this);

        button.setBounds(110,100,100,40);
        label.setBounds(50,200,220,50);
        label.setBackground(Color.PINK);
        label.setHorizontalAlignment(SwingConstants.CENTER);
    }

    public void actionPerformed(ActionEvent e) {
        label.setText("Hello World!");
    }

    public static void main(String[] args) throws Exception {
        HelloWorldApp frame=new HelloWorldApp();
        frame.setBounds(100,100,320,480);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

}

------------------
it's a simple desktop swing program,and runs like

we change it slightly,like this:
------------------

import javax.iswing.JButton;
import javax.iswing.JFrame;
import javax.iswing.JLabel;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class HelloWorldApp extends JFrame implements ActionListener {

    private JLabel label;

    public HelloWorldApp() {
        this.setLayout(null);
        this.setBackground(Color.WHITE);

        JButton button=new JButton("Click Me");
        label=new JLabel();
        this.add(button);
        this.add(label);
        button.addActionListener(this);

        button.setBounds(110,100,100,40);
        label.setBounds(50,200,220,50);
        label.setBackground(Color.PINK);
        label.setHorizontalAlignment(SwingConstants.CENTER);
    }

    public void actionPerformed(ActionEvent e) {
        label.setText("Hello World!");
    }

    public static void main(String[] args) throws Exception {
        HelloWorldApp frame=new HelloWorldApp();
        //frame.setBounds(100,100,320,460);
        //frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }

}

------------------

5. Run/Test in the emulator

then it can runs in the emulator
the command line looks like:
java com.saurik.uicaboodle.Main SwingDelegate HelloWorldApp
the programs runs like

6. Package for deployment

launch the iSwing package tool
fill in all infos
add the content(files and folders)
the D:\temp\Hello\bin is my compile output path

then package

7. Deploy and test in real IPhone

remember your ip

sftp to it

upload your files(using sftp client,here winscp)
at the first time,you also upload and install iSwing-xx.deb

ssh to your iphone
here using putty

install iSwing-xx.deb if you has not installed
install the deb package

restart springboard
here using sbsettings
you can also restart your iphone

you will see the app icon

run it

8. Modify and Upgrade

update our program
------------------

import javax.iswing.*;
import javax.iswing.JButton;
import javax.iswing.JCheckBox;
import javax.iswing.JFrame;
import javax.iswing.JLabel;
import javax.iswing.JProgressBar;
import javax.iswing.JSlider;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class HelloWorldApp extends JFrame implements ActionListener,ReadyListener {

    private JLabel label;

    public HelloWorldApp() {
        this.setLayout(null);
        this.setBackground(Color.WHITE);

        JButton button=new JButton("Click Me");
        label=new JLabel();
        this.add(button);
        this.add(label);
        button.addActionListener(this);

        button.setBounds(110,5,100,40);
        label.setBounds(50,50,220,50);
        label.setBackground(Color.PINK);
        label.setHorizontalAlignment(SwingConstants.CENTER);

        JDatePicker picker=new JDatePicker();
        picker.setBounds(0,105,320,220);
        this.add(picker);

        JSlider slider=new JSlider();
        this.add(slider);
        slider.setBackground(Color.WHITE);
        slider.setBounds(5,330,310,30);

        JProgressBar progress=new JProgressBar(0,100);
        this.add(progress);
        progress.setBounds(5,365,310,15);
        progress.setValue(50);

        ActivityIndicator indicator=new ActivityIndicator();
        this.add(indicator);
        indicator.setBounds(1,1,45,45);
        indicator.addReadyListener(this);

        JCheckBox check=new JCheckBox();
        this.add(check);
        check.setBounds(220,5,90,30);

        Browser browser=new Browser();
        this.add(browser);
        browser.setBounds(5,385,310,300);
        browser.addReadyListener(this);
    }

    public void onReady(ReadyEvent e) {
        Object source = e.getSource();
        if(source instanceof Browser) {
            ((Browser)source).loadUrl("http://www.google.cn/");
        } else if(source instanceof ActivityIndicator) {
            ((ActivityIndicator)source).startAnimating();
        }
    }

    public void actionPerformed(ActionEvent e) {
        label.setText("Hello World!");
    }

    public static void main(String[] args) throws Exception {
        HelloWorldApp frame=new HelloWorldApp();
        frame.setVisible(true);
    }

}

------------------
test in the emulator
there is a browser control below

we need not pack the program again,
we just upload the classes to the phone directly.
the remote path is /Applications/HelloWorldApp.app/

run it

it is easy to start,isn't it?
any questions,please post in the forum,i'll look through the posts frequently.
:)