400 likes | 550 Views
JAVA TM 2 Micro Edition ( J2ME TM ) Technology for Creating Mobile Devices. 李凱雯 kaiwen@java.csie.nctu.edu.tw 蔡文能 tsaiwn@csie.nctu.edu.tw. Introduction. J2EE. J2SE. J2ME. SmartCard. Everything Connected. Customizable,Personal Services .
E N D
JAVATM 2 Micro Edition (J2METM) Technology for Creating Mobile Devices 李凱雯 kaiwen@java.csie.nctu.edu.tw 蔡文能 tsaiwn@csie.nctu.edu.tw
Introduction J2EE J2SE J2ME SmartCard
CLDC:Connected Limitedaaaa Device Configuration CDC:Connected Deviceaaaaa Configuration kilo
What is Configuration? • 為JVM 定義最小的能力和library,使JVM足够小且能够在相同级别的所有設備上執行 • Configuration所需的内存以及提供的處理能力在同一级别的設備上都很類似 • 易於進行可相容性測試 • 定義了兩种Configuration: • Connected, Limited Device Configuration (連接的、有限設備的Configuration) • Connected Device Configuration (連接設備的Configuration)
What is Profile? • 為一些API,作爲Configuration的補充,爲特定的縱向市場或設備類型提供服務 • 爲某種設備領域提供特殊的服務,如蜂巢式電話或個人數位助理 • 定義了一種profile: • Mobile Information Device Profile (移動資訊設備Profile)
Java.* packages for J2ME • J2ME • Supports • java.lang.* • java.io.* • java.util.* • Java.microedition.io.* • KVM (Kilo-bytes Virtual Machine on PalmOS) • Not support basic data types of float and double
J2ME Core Libraries • Core Lib Specification • CLDC • Connected Limited Device Configuration • for devices with limited electronic and computation power • CDC • Connected Device Configuration • eg Setup-Box
Foundation Profile Personal Profile RMI Profile Profile MID : Mobile Information Device PDA : Personal Digital Assistant
JAVA Application Profile Configuration Native APIs OS Device Profile RMI Personal MID PDA Foundation CLDC CDC Configuration
The Goal of KVM • Small, with a static memory in the range 40 Kilobytes to 80 Kilobytes. • Clean and highly portable • Modular and Customizable
Software of KVM • Download Kjava/KVM/KVMutil from sun.com • JDK(J2SE) • j2sdk-1_3_0_02-win.exe • J2ME_CLDC/KVM • j2me_cldc-1_0_2-fcs-winunix.zip • j2me_cldc-1_0_2-fcs-kjava_overlay.zip • POSE(Palm OS Emulator) • emulator-win.zip
Develop J2ME programs • Preverify before run your class file *.java compile *.class preverify *.class *.prc + wrapper.prc executable
Simple Example • HelloWorld.java
HelloWorld.java import com.sun.kjava.*;public class HelloWorld extends Spotlet{ Button exitButton; static Graphics g=Graphics.getGraphics(); public static void main(String[] args) { HelloWorld hw=new HelloWorld(); hw.register(NO_EVENT_OPTIONS); } public HelloWorld() { exitButton=new Button(“exit”, 70, 120); paint(); } • Note that the HelloWorld extends Spotlet private void paint() { g.clearScreen(); g.drawString(“Hello, World”,60,80); exitButton.paint(); } public void penDown(int x,int y) { if(exitButton.pressed(x,y)) { System.exit(0); } }}
Compile and Make PRC file • Compile • javac -g:none -classpath c:\j2me_cldc\bin\api\classes;. -bootclasspath c:\j2me_cldc\bin\api\classes HelloWorld.java • Preverify: output another class in .\output • preverify –classpath c:\j2me_cldc\bin\api\classes;. HelloWorld • Make PRC Executable File • java –classpath c:\j2me_cldc\bin\api\classes -bootclasspath c:\j2me_cldc\bin\api\classespalm.database.MakePalmApp –v HelloWorld
KJAVA API • Package:com.sun.kjava • The classes provided in this package are not part of the CLDC reference implementation • 22 classes
Event handling • Spotlet:provides callbacks for event handling • JDK:inheritable delegation-based • KVM:inheritable After V.1.1
Event handling in Spotlet HelloWorld.prc Bootstrap(wrapper.prc) • Spotlet Framework Events HelloWorld.class Dispatch() keyDown()penDown()/Up()penMove() KVM.prc
Event handling of KVM • Method • keyDown • penDown、penUp andpenMove • beamReceive • unknowEvent
Event handling of KVM (Cont.) • Mode • NO_EVENT_OPTIONS • WANT_SYSTEM_KEYS • Example • EventHandling.java
kAWT • A simplified version of AWT for the KVM • why kAWT ? • the original com.sun.kjava classes included in J2ME CLDC Beta1 and the older EA-Versions of KVM differ from the standard Java UI components in many aspects • Is implemented all lightweight similar to SWING • Event handling:delegation-based
kAWT(Cont.) • Both Spotlet and Frame can be used • Layout • BorderLayout • CardLayout • FlowLayout • GridLayout • GridBagLayout (not available in KAWT)
Software of KAWT • kawt_io_net_pdb.zip • The packages java.awt, java.awt.event, java.awt.image, de.kawt, de.kawt.shell, java.io and java.net. • kawt_io_net.zip • The compiled and preverified kAWT-classes in a jar file. Useful for compilation of own kAWT applications. Extension changed to zip because of download problems.
Example • Prog2_1.java • KawtDemo.java
Kjava手機和傳統WAP手機的差別 • WAP(Wireless Application Protocol)是使移動通訊設備可靠地接入Internet的國際標準。 • WAP手機是集移動電話與移動電腦於一身的通訊工具,它不僅具有普通手機的功能,而且還有收發電子郵件、傳真、瀏覽新聞、查看股市行情等功能。 • 用K Java解決開發周期大大縮短,方便移植到其他平臺 支援動態下載、升級, 第三方開發者易於介入 • K Java支持Client方式access Internet直接存取Internet全部資訊,不同的Client存取各種各樣的文件,最高效率的on-line交易,存取本地存儲區,提高效率
集最新高科技于一身的Motorola A6288 • J2ME软件平台 • 大陸第一款预装J2ME软件平台的手机J2ME(Java 2 Micro Edition)俗称KJava • GPRS网络 • A6288是中国第一部支持GPRS (General Packet Radio Service)网络的手机,即通用分组无线业务,它是一种允许信息通过移动电话网络传递的非语音增值服务,是现阶段普遍看好,也是最容易实现的移动设备高速上网技术。与传统的GSM相比,GPRS拥有明显的优势
Motorola A6288連接Internet方式 K-Java MOBILEPHONE TELECOM Internet K-Java Telecom Internet GSM/GPRS/3G Http Socket(Tcp/Ip) Http/Socket(Tcp/Ip) Motorola A6288: 1.內置J2Me平臺 2. 支援收發E-Mail功能 3. 本身可以作爲無線Modem給您的筆記本提供上網功能 Kjava手機與傳統WAP聯接入Internet方式不同,省略掉了WAP GateWay, 利用K-Java Client程式,可以通過Http或者Socket協定進行通訊,大大的提高了網路的傳輸速度。 PC
Jini and Java2 Technologies Jini Networking Technology Jini Device and Surrogate Architecture RMI Profile JSR 66 Personal Profile JSR 62 Profiles…. MID Profile Foundation Profile JSR 46 Connected Device Configuration (CDC) Connected Limited Device Config (CLDC) Enterprise Edition Standard Edition Micro Edition No VM
J2ME interoperability with J2SE 1.2.x or higher Targeted at devices with 2.5 Mbytes minimum ROM 1 Mbytes minimum RAM TCP/IP connectivity J2ME CDC/Foundation Profile Objectives for J2ME RMI Profile
Relationship to J2SE™ 1.3 APIs • Full RMI call semantics • Marshalled object support • RMI wire protocol (JRMP) • Export of remote objects • Client/server side DGC • Activator interface and client side activation protocol • Registry interfaces and export of Registry remote object
RMI through firewalls via proxies RMI multiplexing protocol Implementation model for “Activatable” Remote Object Deprecated methods, classes and interfaces Support for JDK 1.1 stub/skeleton protocols Stub and skeleton compiler (rmic). See java.sun.com/aboutJava/communityprocess/jsr/jsr_066_rmime.html Parts of J2SE RMI not included
References • http://www.sun.com/software/communitysource/j2me • http://webdev.apl.jhu.edu/~rbe/kvm/ • http://java.sun.com/products/cldc/ • http://www.sun.com/software/communitysource/j2me/cdc/ • http://www.billday.com/j2me/ • http://java.sun.com/products/j2mewtoolkit/