計(jì)算機(jī)專(zhuān)業(yè)畢業(yè)設(shè)計(jì)(論文)外文翻譯-J2ME導(dǎo)學(xué)_第1頁(yè)
計(jì)算機(jī)專(zhuān)業(yè)畢業(yè)設(shè)計(jì)(論文)外文翻譯-J2ME導(dǎo)學(xué)_第2頁(yè)
計(jì)算機(jī)專(zhuān)業(yè)畢業(yè)設(shè)計(jì)(論文)外文翻譯-J2ME導(dǎo)學(xué)_第3頁(yè)
計(jì)算機(jī)專(zhuān)業(yè)畢業(yè)設(shè)計(jì)(論文)外文翻譯-J2ME導(dǎo)學(xué)_第4頁(yè)
計(jì)算機(jī)專(zhuān)業(yè)畢業(yè)設(shè)計(jì)(論文)外文翻譯-J2ME導(dǎo)學(xué)_第5頁(yè)
已閱讀5頁(yè),還剩9頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、英文原文J2ME step by stepJ2me overviewIntroductionThis section will get you started using J2ME. We'll begin by defining J2ME, then we'll discuss its general architecture and learn about the devices J2ME targets. As part of the architecture discussion, we will provide an overview about profiles a

2、nd configurations. (We'll address the details of both profiles and configurations in later sections.) We also will cover briefly some considerations for packaging and deploying J2ME applications. What is J2ME?Sun Microsystems defines J2ME as "a highly optimized Java run-time environment tar

3、geting a wide range of consumer products, including pagers, cellular phones, screen-phones, digital set-top boxes and car navigation systems." Announced in June 1999 at the JavaOne Developer Conference, J2ME brings the cross-platform functionality of the Java language to smaller devices, allowi

4、ng mobile wireless devices to share applications. With J2ME, Sun has adapted the Java platform for consumer products that incorporate or are based on small computing devices. General J2ME architectureJ2ME uses configurations and profiles to customize the Java Runtime Environment (JRE). As a complete

5、 JRE, J2ME is comprised of a configuration, which determines the JVM used, and a profile, which defines the application by adding domain-specific classes. The configuration defines the basic run-time environment as a set of core classes and a specific JVM that run on specific types of devices.The pr

6、ofile defines the application; specifically, it adds domain-specific classes to the J2ME configuration to define certain uses for devices. The following graphic depicts the relationship between the different virtual machines, configurations, and profiles. It also draws a parallel with the J2SE API a

7、nd its Java virtual machine. While the J2SE virtual machine is generally referred to as a JVM, the J2ME virtual machines, KVM and CVM, are subsets of JVM. Both KVM and CVM can be thought of as a kind of Java virtual machine - it's just that they are shrunken versions of the J2SE JVM and are spec

8、ific to J2ME.Configurations overviewThe configuration defines the basic run-time environment as a set of core classes and a specific JVM that run on specific types of devices. Currently, two configurations exist for J2ME, though others may be defined in the future: · Connected Limited Device Co

9、nfiguration (CLDC) is used specifically with the KVM for 16-bit or 32-bit devices with limited amounts of memory. This is the configuration (and the virtual machine) used for developing small J2ME applications. Its size limitations make CLDC more interesting and challenging (from a development point

10、 of view) than CDC. CLDC is also the configuration that we will use for developing our drawing tool application. An example of a small wireless device running small applications is a Palm hand-held computer. · Connected Device Configuration (CDC) is used with the C virtual machine (CVM) and is

11、used for 32-bit architectures requiring more than 2 MB of memory. An example of such a device is a Net TV box. CDC is outside scope of this tutorial.Profiles overviewThe profile defines the type of devices supported by your application. Specifically, it adds domain-specific classes to the J2ME confi

12、guration to define certain uses for devices. Profiles are built on top of configurations. Two profiles have been defined for J2ME and are built on CLDC: KJava and Mobile Information Device Profile (MIDP). These profiles are geared toward smaller devices. A skeleton profile on which you create your o

13、wn profile, the Foundation Profile, is available for CDC. However, for this tutorial, we will focus only on profiles built on top of CLDC for smaller devices. We will discuss both of these profiles in later sections and will build some sample applications using KJava and MIDP. Devices J2ME targetsTa

14、rget devices for J2ME applications developed using CLDC generally have the following characteristics:· 160 to 512 kilobytes of total memory available for the Java platform · Limited power, often battery powered · Network connectivity, often with a wireless, inconsistent connection and

15、 with limited bandwidth · User interfaces with varying degrees of sophistication; sometimes with no interface at allSome devices supported by CLDC include wireless phones, pagers, mainstream personal digital assistants (PDAs), and small retail payment terminals. According to Sun Microsystems, t

16、arget devices for CDC generally have the following characteristics: · Powered by a 32-bit processor · Two megabytes or more of total memory available for the Java platform · Devices that require the full functionality of the Java 2 "Blue Book" virtual machine · Network

17、connectivity, often with a wireless, inconsistent connection and with limited bandwidth · User interfaces with varying degrees of sophistication; sometimes with no interface Some devices supported by CDC include residential gateways, smartphones and communicators, PDAs, organizers, home applian

18、ces, point-of-sale terminals, and car navigation systems. Developing j2me applicationsIntroductionIn this section, we will go over some considerations you need to keep in mind when developing applications for smaller devices. We'll take a look at the way the compiler is invoked when using J2SE t

19、o compile J2ME applications. Finally, we'll explore packaging and deployment and the role preverification plays in this process. Design considerations for small devicesDeveloping applications for small devices requires you to keep certain strategies in mind during the design phase. It is best to

20、 strategically design an application for a small device before you begin coding. Correcting the code because you failed to consider all of the "gotchas" before developing the application can be a painful process. Here are some design strategies to consider: · Keep it simple. Remove un

21、necessary features, possibly making those features a separate, secondary application. · Smaller is better. This consideration should be a "no brainer" for all developers. Smaller applications use less memory on the device and require shorter installation times. Consider packaging your

22、 Java applications as compressed Java Archive (jar) files.· Minimize run-time memory use. To minimize the amount of memory used at run time, use scalar types in place of object types. Also, do not depend on the garbage collector. You should manage the memory efficiently yourself by setting obje

23、ct references to null when you are finished with them. Another way to reduce run-time memory is to use lazy instantiation, only allocating objects on an as-needed basis. Other ways of reducing overall and peak memory use on small devices are to release resources quickly, reuse objects, and avoid exc

24、eptions.Performance considerationsCode for performance. Here are some ways to code with the aim to achieve the best performance: · Use local variables. It is quicker to access local variables than to access class members. · Avoid string concatenation. String concatenation decreases perform

25、ance and can increase the application's peak memory usage. · Use threads and avoid synchronization. Any operation that takes more than 1/10 of a second to run requires a separate thread. Avoiding synchronization can increase performance as well. · Separate the model using the model-vie

26、w-controller (MVC). MVC separates the logic from the code that controls the presentation. Compiling considerationsAs with any other Java application, you compile the application before packaging and deploying it. With J2ME, however, you use the J2SE compiler and need to invoke it with the appropriat

27、e options. In particular, you need to use the -bootclasspath option to instruct the compiler to use the J2ME classes, not the J2SE classes. Do not place the configuration classes in the compiler's CLASSPATH. This approach will lead to run-time errors, because the compiler automatically searches

28、the J2SE core classes first, regardless of what is in the CLASSPATH. In other words, the compiler will not catch any references to classes or methods that are missing from a particular J2ME configuration, resulting in run-time errors when you try to run your application. Packaging and deployment con

29、siderationsBecause J2ME is designed for small devices with limited memory, much of the usual Java preverification has been removed from the virtual machine to allow for a smaller footprint. As a result, it is necessary to preverify your J2ME application before deployment. An additional check is made

30、 at run time to make sure that the class has not changed since preverification. Exactly how to perform the preverification, or checking the classes for correctness, depends on the toolkit. CLDC comes with a command-line utility called preverify, which does the actual verification and inserts extra i

31、nformation into the class files. MIDP uses the wireless toolkit, which comes with a GUI tool, though this too can be run from the command line. Deployment depends on the platform to which you are deploying. The application must be packaged and deployed in a format suitable for the type of J2ME devic

32、e, as defined by the profile.Setting up your development environmentIntroductionIn this section, we will see how to download and install the necessary software required for developing J2ME applications. We begin by downloading and installing CLDC under Windows or UNIX. The current CLDC 1.0 release c

33、ontains a CLDC implementation for Win32, Solaris, and Linux platforms. We'll then install the KVM on your Palm hand-held device and look at compiling the Palm database development tools. Next, we'll show you how to download and install the Palm OS Emulator (POSE) and how to transfer a ROM im

34、age of a Palm device to your PC for use with the emulator. Finally, we'll look at downloading and installing the J2ME Wireless Toolkit, which is used for developing J2ME applications for MIDP devices. Downloading and installing CLDC on Win32 or UNIXTo install CLDC and the Sun's KVM software

35、on a Windows or UNIX platform: 1. Download the CLDC Two packages are downloaded and must be installed: j2me_cldc-1_0_2-fcs-winunix.zip and j2me_cldc-1_0_2-fcs-kjava_overlay.zip.2. Unzip the first package. o Under Windows you may want to unzip the contents into the root directory, c:o Under UNIX, unz

36、ip the contents into your preferred directory. This may be your home directory, or if you are installing for all users of the machine install wherever you normally install shared application files (for example, this is usually something like /usr/local or /opt.A new folder, j2me_cldc, is created ben

37、eath the installation directory, and it contains the following subdirectories: jam, docs, build, tools, api, kvm, samples, and bin.3. Unzip the second package to the j2me_cldc directory just created by your CLDC installation. For example, c:j2me_cldc under Windows, or something like /usr/local/j2me_

38、cldc or /opt/j2me_cldc under UNIX. If prompted, overwrite any files that already exist.4. Add the j2me_cldc/bin directory to your PATH to save typing the full path every time you want to run the CLDC programs kvm and preverify. Installing the Palm OS Emulator (POSE)The Palm OS Emulator (POSE) applic

39、ation software emulates different models of PDAs. An emulator allows you to develop, test, and debug PDA applications before downloading them to your PDA. POSE is free and available at the Palm OS Emulator Web siteA binary version of this is only available for Windows. Although POSE also is availabl

40、e to run under UNIX, you must download the source files from the Palm OS Web site and compile them yourself for your specific UNIX platform. To download and install POSE under Windows: 1. Download the latest POSE zip file from Palm OS Web site.2. Extract the contents of the zip file into its own dir

41、ectory.3. The emulator.exe file now exists in the POSE installation directory. When launched, emulator.exe runs the Palm OS Emulator. Downloading and installing the J2ME Wireless ToolkitThe J2ME Wireless Toolkit provides a complete development environment to write and test MIDP applications. The dow

42、nload includes tools, documentation, an emulation environment, examples, and a module to integrate with Forte for Java.Currently, the J2ME Wireless Toolkit is available for Windows 98 Second Edition, Windows NT 4.0, and Windows 2000 only. Windows 95 is not supported. Solaris and Linux versions of th

43、e J2ME Wireless Toolkit are under consideration at the time of this writing.Follow these steps to install the J2ME Wireless Toolkit under Windows: 1. download the j2me wireless toolkit2. Run the j2me_wireless_toolkit-1_0_1-fcs.exe program to install the Wireless Toolkit. When you are prompted for th

44、e installation directory, be sure that the fully qualified path to the install directory does not contain any spaces. This will help you avoid possible problems later on when using the toolkit.If you plan to use Forte for Java for development, select Integrated setup in the Setup Type dialog.英文譯文J2M

45、E導(dǎo)學(xué)J2ME概覽J2ME 是什么?Sun Microsystems 將 J2ME 定義為“一種以廣泛的消費(fèi)性產(chǎn)品為目標(biāo)的的高度優(yōu)化的 Java 運(yùn)行時(shí)環(huán)境,包括尋呼機(jī)、移動(dòng) 、可視 、數(shù)字機(jī)頂盒和汽車(chē)導(dǎo)航系統(tǒng)。自從 1999 年 6 月在 JavaOne Developer Conference 上聲明之后,J2ME 為小型設(shè)備帶來(lái)了 Java 語(yǔ)言的跨平臺(tái)功能,允許移動(dòng)無(wú)線設(shè)備共享應(yīng)用程序。有了 J2ME,Sun 已經(jīng)使 Java 平臺(tái)能夠適應(yīng)集成了或基于小型計(jì)算設(shè)備的用戶產(chǎn)品。 J2ME 總體架構(gòu)J2ME 使用配置和簡(jiǎn)表定制 Java 運(yùn)行時(shí)環(huán)境 (JRE)。作為一個(gè)完整的 JRE,J2

46、ME 由配置和簡(jiǎn)表組成,配置決定了使用的 JVM,而簡(jiǎn)表通過(guò)添加特定于域的類(lèi)來(lái)定義應(yīng)用程序。 配置將根本運(yùn)行時(shí)環(huán)境定義為一組核心類(lèi)和一個(gè)運(yùn)行在特定類(lèi)型設(shè)備上的特定 JVM。簡(jiǎn)表定義應(yīng)用程序;特別地,它向 J2ME 配置中添加特定于域的類(lèi),定義設(shè)備的某種作用。以下圖描述了不同的虛擬機(jī)、配置和簡(jiǎn)表之間的關(guān)系。它同時(shí)把 J2SE API 和它的 Java 虛擬機(jī)進(jìn)行了比擬。雖然 J2SE 虛擬機(jī)通常被稱為一種 JVM,但是 J2ME 虛擬機(jī)、KVM 和 CVM 都是 JVM 的子集。KVM 和 CVM 均可被看作是一種 Java 虛擬機(jī) - 它們是 J2SE JVM 的壓縮版,并特定于 J2ME。

47、配置概述配置將根本運(yùn)行時(shí)環(huán)境定義為一組核心類(lèi)和一個(gè)運(yùn)行在特定類(lèi)型設(shè)備上的特定 JVM。雖然還可能在將來(lái)定義其他的配置,但當(dāng)前 J2ME 存在兩種配置: · 連接限制設(shè)備配置 (CLDC) 特別與 KVM 一起用于內(nèi)存有限的 16 位或 32 位設(shè)備。這是用于開(kāi)發(fā)小型 J2ME 應(yīng)用程序的配置虛擬機(jī)。從開(kāi)發(fā)的角度來(lái)看它的大小限制讓它比 CDC 更有趣、更具挑戰(zhàn)性。CLDC 同時(shí)還是用于開(kāi)發(fā)繪圖工具應(yīng)用程序的配置。 Palm 電腦便是一個(gè)運(yùn)行小應(yīng)用程序的小型無(wú)線設(shè)備的例如。· 連接設(shè)備配置 (CDC) 與 C 虛擬機(jī) (CVM) 一起使用,用于要求內(nèi)存超過(guò) 2 兆的 32 位體

48、系結(jié)構(gòu)?;ヂ?lián)網(wǎng)電視機(jī)頂盒便是這類(lèi)設(shè)備的一個(gè)例如。簡(jiǎn)表概述簡(jiǎn)表定義了您的應(yīng)用程序所支持的設(shè)備類(lèi)型。特別地,它向 J2ME 配置添加了特定于域的類(lèi)來(lái)定義設(shè)備的某種作用。簡(jiǎn)表建立在配置的頂部。已經(jīng)為 J2ME 定義了兩種簡(jiǎn)表:KJava 和移動(dòng)信息設(shè)備簡(jiǎn)表 (MIDP),它們也被建立在 CDLC 上。這兩種簡(jiǎn)表適用于小型設(shè)備。 有一種綱要簡(jiǎn)表,您可以在它的上面創(chuàng)立自己的簡(jiǎn)表,這種綱要簡(jiǎn)表也稱為根底表,可供 CDC 使用。然而,在本教程中,我們只重點(diǎn)介紹建立在 CLDC 頂部,適用于小型設(shè)備的簡(jiǎn)表。 我們將在后面的章節(jié)中討論上述這些簡(jiǎn)表,還會(huì)使用 KJava 和 MIDP 建立一些例如應(yīng)用程序。 J2

49、ME 目標(biāo)設(shè)備使用 CLDC 開(kāi)發(fā)的 J2ME 應(yīng)用程序的目標(biāo)設(shè)備通常具有以下特征:· 可供 Java 平臺(tái)使用的 160 到 512 千字節(jié)的總內(nèi)存· 功率有限,常常是電池供電· 網(wǎng)絡(luò)連通性,常常是無(wú)線的、不一致的連接并且?guī)捰邢?#183; 用戶接口混亂,程度參差不齊;有時(shí)根本就沒(méi)有接口一些 CLDC 支持的設(shè)備,包括無(wú)線 、尋呼機(jī)、主流個(gè)人數(shù)字助手 (PDA),以及小型零售支付終端。 依照 Sun Microsystems,CDC 的目標(biāo)設(shè)備通常具有以下特征:· 使用 32 位處理器· 2 兆字節(jié)或更多可供 Java 平臺(tái)使用的總內(nèi)存 &

50、#183; 設(shè)備要求的 Java 2 “藍(lán)皮書(shū)虛擬機(jī)的全部功能 · 網(wǎng)絡(luò)連通性,常常是無(wú)線的、不一致的連接并且?guī)捰邢?· 用戶接口混亂,程度參差不齊;有時(shí)根本就沒(méi)有接口一些 CDC 支持的設(shè)備,包括常駐網(wǎng)關(guān)、智能 和通訊器、PDA、管理器、家用電器、銷(xiāo)售網(wǎng)點(diǎn)終端以及汽車(chē)導(dǎo)航系統(tǒng)。 開(kāi)發(fā)J2ME應(yīng)用程序介紹在這一章中,我們將復(fù)習(xí)一下在為小型設(shè)備開(kāi)發(fā)應(yīng)用程序時(shí)需要牢記的一些考前須知。我們將看一下在使用 J2SE 編譯 J2ME 應(yīng)用程序時(shí)調(diào)用編譯器的方法。最后我們將探究打包和部署,以及在這個(gè)過(guò)程中提前驗(yàn)證所扮演的角色。 設(shè)計(jì)開(kāi)發(fā)小型設(shè)備應(yīng)用程序要注意的事項(xiàng)為小型設(shè)備開(kāi)發(fā)應(yīng)用程

51、序,需要您在設(shè)計(jì)階段制定某種策略。最好是在開(kāi)始編寫(xiě)代碼之前,戰(zhàn)略性地為小型設(shè)備設(shè)計(jì)應(yīng)用程序。由于無(wú)法考慮到所有的 "gotchas" ,在開(kāi)發(fā)應(yīng)用程序之前更正代碼是一件很痛苦的工作。 下面是一些可以考慮的設(shè)計(jì)謀略: · 保持程序簡(jiǎn)單。除去不必要的功能,如果可能的話,將它們做成獨(dú)立的、次要的應(yīng)用程序。 · 程序越小越好。這一點(diǎn)對(duì)所有的開(kāi)發(fā)者來(lái)說(shuō)應(yīng)該是顯而易見(jiàn)的。越小的程序占用的設(shè)備內(nèi)存越少,并且花費(fèi)的安裝時(shí)間越少??煽紤]將您的 Java 應(yīng)用程序打包,作為壓縮的 Java 檔案 (jar) 文件。· 運(yùn)行時(shí)占用最少的內(nèi)存。為 盡可能減少運(yùn)行時(shí)占用

52、的內(nèi)存,使用標(biāo)量類(lèi)型代替對(duì)象類(lèi)型。同時(shí),不依賴?yán)占绦?。您?yīng)該在使用完對(duì)象時(shí)將對(duì)象引用置空,這樣可有效管理內(nèi)存。另外一種 減少運(yùn)行時(shí)所需內(nèi)存的方法是使用“惰性實(shí)例,它僅在必需時(shí)才分配對(duì)象。其它一些減少小型設(shè)備上過(guò)量和峰值內(nèi)存使用的方法有快速釋放資源、重新使用對(duì)象以 及防止異常。 性能考前須知為性能而編碼。下面有一些以獲得最優(yōu)性能為目標(biāo)的編碼方法:· 使用局部變量。訪問(wèn)局部變量比訪問(wèn)類(lèi)成員更快。· 防止字符串串聯(lián)。字符串串聯(lián)不僅會(huì)降低性能,而且會(huì)增加應(yīng)用程序的內(nèi)存峰值占用量。· 使用線程,防止同步。任何運(yùn)行時(shí)間超過(guò) 1/10 秒的操作都需要一個(gè)獨(dú)立的線程。防止同

53、步同樣能提高性能。· 使用模型視圖控制器 (MVC) 別離模型。MVC 將代碼中控制顯示的邏輯別離出來(lái)。 編譯考前須知同其它的 Java 應(yīng)用程序一樣,您在打包和部署應(yīng)用程序之前要先進(jìn)行編譯。盡管有了 J2ME,您仍然使用 J2SE 編譯器并且需要用適當(dāng)?shù)倪x項(xiàng)來(lái)進(jìn)行調(diào)用。特別的,您需要使用 -bootclasspath 選項(xiàng)來(lái)指示編譯器使用 J2ME 類(lèi),而不是 J2SE 類(lèi)。不要在編譯器的 CLASSPATH 中設(shè)置配置類(lèi)。這樣將導(dǎo)致運(yùn)行時(shí)錯(cuò)誤,因?yàn)椴还?CLASSPATH 中有什么,編譯器將首先自動(dòng)搜索 J2SE 的核心類(lèi)。換句話說(shuō),編譯器將無(wú)法引用特定 J2ME 配置中缺少的類(lèi)

54、或方法,結(jié)果導(dǎo)致在嘗試運(yùn)行應(yīng)用程序時(shí)出現(xiàn)運(yùn)行時(shí)錯(cuò)誤。 打包和部署考前須知由于 J2ME 是為內(nèi)存有限的小型設(shè)備設(shè)計(jì)的。大局部常用的 Java 提前驗(yàn)證已經(jīng)從虛擬機(jī)中除去以形成一個(gè)較小的覆蓋區(qū)域。結(jié)果,在配置之前提前驗(yàn)證 J2ME 應(yīng)用程序就很有必要。在運(yùn)行時(shí)會(huì)附加一個(gè)檢查以確保這個(gè)類(lèi)在提前驗(yàn)證之后還沒(méi)有改變過(guò)。 如何嚴(yán)格執(zhí)行提前驗(yàn)證或者檢查類(lèi)的正確性依靠的是工具包。CLDC 提供一個(gè)稱為提前驗(yàn)證的命令行實(shí)用程序,它能夠進(jìn)行實(shí)際的驗(yàn)證并且可以把一些額外的信息插入到類(lèi)文件中去。MIDP 使用無(wú)線工具包,這種工具包提供一種 GUI 工具,也可從命令行運(yùn)行這種工具。部署工作取決于您要部署的平臺(tái)。應(yīng)用程序必須以一種適合 J2ME 設(shè)備類(lèi)型的格式進(jìn)行打包和配

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論