2010年4月12日 星期一

J2ME + Eclipse + jar implement

J2ME + Eclipse 安裝流程可參考. http://changyy.pixnet.net/blog/post/25766488 安裝完成後,可用Hellow World做測試,記得在HelloWorld.jad底下做class link,不然模擬器會找不到確切的位置. 會造成"com.sun.kvem.midletsuite.InvalidJadException: Reason = 22" Error. 用 HelloWorld(project named) -> J2ME -> Create Package 來產生 .jar檔. 最後put .jar到你的Cell Phone上,就可以work了.
how to handle the "com.sun.kvem.midletsuite.InvalidJadException: Reason = 22",
you can reference

2010年4月11日 星期日

J2ME Wireless Toolkit WMA (JSR102)

Wireless Toolkit for JSR J2ME 的Entry point (commandAction),像是 *.java 的main. 其中定義了App start, pause,destroy. 可以在內部填入我們所要的method... public void commandAction(Command cmd, Displayable disp) {} protected void startApp() { } protected void pauseApp() {} protected void destroyApp(boolean bool) {} 在Entry point (commandAction)會check 現在所輸入的command,如Exit , Send Message.... 每個command 會有對應的class, 有點像是Action listen的動作. 底下是 SMS Sender的範例,會定義要傳的Address(Cell Phone Number), Message 內容... SMS Sender.java
public void run() {
        String address = destinationAddress;

        MessageConnection smsconn = null;

        try {
            /** Open the message connection. */
            smsconn = (MessageConnection)Connector.open(address);

            TextMessage txtmessage =
                (TextMessage)smsconn.newMessage(MessageConnection.TEXT_MESSAGE);
            txtmessage.setAddress(address);
            txtmessage.setPayloadText(messageBox.getString());
            smsconn.send(txtmessage);
        } catch (Throwable t) {
            System.out.println("Send caught: ");
            t.printStackTrace();
        }

        if (smsconn != null) {
            try {
                smsconn.close();
            } catch (IOException ioe) {
                System.out.println("Closing connection caught: ");
                ioe.printStackTrace();
            }
        }
    }
code ref: J2ME WMAdemo PS: 請把 port的地方拿掉, 因為我們沒有模擬Receive端透過port來做連接.

2010年4月8日 星期四

OBEXFTP 4 BlueFTP

Pic Ref: http://www.designftp.com/
BeWare:
1. make sure you have installed wiki:OpenObex? and wiki:BluezLib? 2. download obexftp here 3. extract the tarball to a temporary folder 4. execute the following %export OPENOBEX_LIBS="-L/usr/lib -lopenobex" %export OPENOBEX_CFLAGS="-I/usr/include/openobex/ -I/usr/include" %./configure --prefix=/usr %make %make install PS: the OBEXFTP not support java language currently, so we choice the perl language.
Perl
OBEXFTP install
OBEX FTP doc 4 perl
getting start with OBEXFTP