由于自己一直用的是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