程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> JAVA編程入門知識 >> 用Java在Palm和Pocket PC上編程

用Java在Palm和Pocket PC上編程

編輯:JAVA編程入門知識

  由於自己一直用的是Java,看不慣C的易錯性和C++的復雜性,再加上論壇上很多朋友都不了解SuperWaba這個偉大的Java虛擬機——世界上還有第二台VM能夠同時在台式機(Java applet)、Palm OS和Pocket PC上跑的嗎?沒有!!
  
  1.SuperWaba是什麼東西?
  
  SuperWaba的前身是Waba,而Waba現在已經差不多死了……最初SW的原意只是Waba上的一個擴展,但是後來一發不可收拾,在經歷的大大小小的改進和更新換代後成為了現在的SW。
  
  優點:
  
  1. 跨平台兼容性超高,一個程序基本不用改動,重新編譯一下就可以在Palm OS或PPC上跑;
  
  2. 豐富的API,可以使用到Symbol的條形碼識別及擴展卡等等;
  
  3.可以方便的從Palm OS style換到非Palm OS style;
  
  4. SW的更新速度驚人的快,平均每個月都有新的版本發布!
  
  5.最重要的一條……它是完全免費的,而且遵守GPL協議,源代碼全部公開,並放在sourceforge上。
  
  缺點:
  
  1.比起用CW寫的C程序會(當然)慢一些,但是下周一(12月15號)發布的SW4.1將是ARM native,到時候會有很明顯的速度提升;
  
  2.目前還不支持中文,但即將到來的SW 4.1將會!!(它的官方網站上就用中文寫著:Full Unicode support (UfoLib) – ready 在下一版本(4.1)中將會假如對中文的支持。
  
  3.比C程序能用到的API會少一些
  
  以下是已知的SW支持的OS:
  
  Palm OS 3到5.2.1(HandSpring的OS3.1 需要打個補丁才能跑)
  Windows CE 從2到3(CE.NET還沒試過)
  Pocket PC從2000一直到2003(只能用一個字形容:爽!那個程序能支持這麼多的OS和處理器框架!)
  
  以下是已知的SW支持的設備
  
  Palm OS 設備
  
  Handspring: Treo 180, Visor Pro (PalmOS 3.5), Visor Platinum, Visor Prism, Treo 600 (!!!)
  Palm:
  o Professional, III, IIIx, IIIc, IIIe, V, Vx
  o M105, M500, M505, M515, M125, Palm 130
  o Zire, Zire 71, Zire21
  o Tungsten C, Tungsten W, Tungsten T, Tungsten T2, Tungsten T3, Tungsten E
  Samsung: SPH-I330, Kyocera Smartphone 6035, Kyocera 7135
  Sony CLIE: S300, T-615, S360, TG50, N770C/E, NX70V, NX60, SJ30, SL10, SJ33, SJ20
  Symbol: SPT 1500, 1550 and 1700
  Handera 330(不支持虛擬手寫區;而且不知為什麼字體變成了小字體)
  
  Windows CE/Pocket PC 設備
  
  Compaq: iPaq 3670, iPaq H3970, iPaq 3900, iPaq 1910, Pocket PC Aero 1550
  Dell: Axim A5, Axim X5
  HP: Jornada 540 (SH3), Jornada 680/690
  HTC: Falcon
  Symbol: PDT8100 (Pocket PC 3.0), PDT8146 (Pocket PC 2002)
  Toshiba: e350 Intel PXA
  Vandem: Clio (HPC 2.11) - cabs don't work but the files can be installed manually for MIPS
  ViewSonic: V35, V37
  
  32-bit Windows
  
  Windows 98
  Windows NT
  Windows XP
  windows 2000
  
  2. 如何獲得SuperWaba
  
  SuperWaba的官方網頁:www.superwaba.com.br
  
  要下載它的SDK話,得先注冊(免費):點Sign Up,然後按照提示完成。
  注冊好了後,點Downlaod,登陸後點Download SuperWaba SDK即可。
  
  這裡推薦一個很不錯的免費IDE:Tauschke MobileCreator 1.7,可以到 http://www.tauschke.com/download/index.Html 去下載。
  
     
  VisualWaba是一個法國人用Java寫的Visual IDE,可惜是共享軟件,有誰能……
  
  目前大多數人用的是Eclipse,這個想必熟悉Java的朋友都知道吧,是完全公開和免費的,有位大蝦已經寫了個Superwaba plugin, 下載的鏈接請在樓下找。這裡是plugin的快速教程:http://superwaba-ide.sourceforge.net/usage.html
  
  假如在使用Superwaba中有什麼困難或建議,不妨訂閱一下superwaba的新聞組:news://news.superwaba.net ,非常有幫助的(外加鍛煉英文!其實superwaba的老大guich是巴西人……從.br這個國家域名就可以看得出來,superwaba是很國際化的,成員多來自德國、法國等等……但是大家都用英語!)
  
  O'Reilly的OnJava.com有一個不錯的Waba教程:http://www.onjava.com/pub/a/onjava/2001/04/19/java_palm.html
  http://www.onjava.com/pub/a/onjava/2001/06/19/waba.html
  
  狂暈……昨天夜裡23:48,superwaba 4.1 正式發布,現在官方的網頁上竟然說……竟然說下個版本會有:
  Native ARM VM for Palm OS 5, expecting 4-8 times faster……
  5-15 times faster VM for Windows CE using the SDL (and, in XScale processors, boosted by Intel's optimized compiler)
  ……最恐怖的是……下個版本將增加對Linux PDA, Symbian V.7和Brew(雖然我不知道這是什麼玩藝)的支持!!!!
  
  英文好的朋友可以看看superwaba老大guich剛給我發的SW簡介:
  
  SuperWaba is a Java-like VM for PDAs. Can run in PalmOS, in Windows CE/PocketPC devices and in Windows 98 and beyond, and is fully emulated under JDK and browser. Have support for Exceptions, Threads, lots of user interface controls, double and long 64 bit types, supports Grayscale in all PalmOS devices starting 2.0, supports Color, has a beautiful set of 3d controls, supports JNI and Java libraries, its fast and small, lets you use all device's memory if needed, supports Symbol scanners, bluetooth, sockets and serial/IR. Also supports html and full UNICODE range (chinese, japanese, korean, etc).
  
  You can make programs using your favorite Java IDE, debug everything in desktop and when finished just deploy it in the device. There are several libraries added by users that enhance the basic set of classes. The programs are totaly portable between the platforms, and even the database is also portable! SuperWaba has more than 10000 members from 150 countries worldwide. Welcome to the world of easy cross-platform!
  
  SuperWaba 4.1 (December 15, 2003)
  
  .Full Unicode Support! (Japanese, Chinese, Korean, etc) .New XML package .New Html Container .New HtmlBrowser .Support for Gif/Jpeg/Png library .Support for Treo 600, Intermec Norand 600, Zire 21, Mono WinCE devices .Improved Image loading speed .Now you can add a txt file using Warp and read it directly (Vm.getFile) .Lots of bug fixes
  
  3. 開始用SuperWaba編程!
  
  雖然Eclipse要比MobileCreator強大的多,但是剛開始還是先從簡單的入手吧!安裝完Tauschke MobileCreator 1.72並啟動後,點“Project”,“New…”,然後輸入工程的名字,這裡就隨便取一個我最常用的Faint吧 :) 記住要把Create MainWindow Class打上鉤,要不然你還得自己從零開始寫!
  
     
  點完OK後,你會發現左邊的Source欄多了一個Faint.java文件,這就是我們剛剛創建的MainWindow class。所有的SuperWaba程序都要有一個並且只能有一個MainWindow class,否則後果自負!這個MainWindow就是主窗口啦……
  
  好,現在就先享受一下一行代碼也沒有打的成果吧!點工具欄最右邊的綠色旗子圖標(Save All, Compile and Start)或者按F10(怎麼聽起來有點像老美的轟炸機??),只要你最開始的路徑全都設對了,現在就會看到一個可愛的Java applet,上面只有一個menu bar Faint……
  
  用鼠標點擊它!瞧,標准的Palm菜單!咦,為什麼點了Options沒反應??廢話,咱們還沒開始寫event handler呢,要有反應的話就見鬼了!
  
  好,先看看代碼:
  
  import waba.ui.*;import waba.fx.*;public class Faint extends MainWindow {String col0[] = {"Options","Cut","Copy","Paste"};String col1[] = {"About Faint","Info"};public Faint() {setDoubleBuffer(true);setBorderStyle(TAB_ONLY_BORDER);setTitle("Faint");setMenuBar(new MenuBar(new String[][]{col0,col1}));}public void onStart() {}public void onEvent(Event event) {}public void onPaint(Graphics g) {} }
  
  最開始的兩行import,把一些最常用的SW classes給導入。其它的還有:
  
  waba.fx Classes related to Graphics, fonts, geometric classes (Rect, Coord), Image, sound. waba.io Input output basic classes, to Access PDB files (represented by a Catalog), sockets, serial port, and some utility classes to make easier dealing with IO. waba.sys Classes that contains functions to deal with the underlying Operating System characteristics and configurations, and convertion classes. waba.ui The most important package, with all user interface controls you need to create good and fast programs. waba.utilUtility classes, to deal with date, random number generation, and data strUCtures (Vectors and Hashtables).
  
  除此之外,SW還有Extension Packages,可以附加使用。具體細節請看documentat
 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved