计算机专业毕业设计论文外文翻译J2ME导学

上传人:无*** 文档编号:141755044 上传时间:2022-08-24 格式:DOC 页数:13 大小:123.50KB
收藏 版权申诉 举报 下载
计算机专业毕业设计论文外文翻译J2ME导学_第1页
第1页 / 共13页
计算机专业毕业设计论文外文翻译J2ME导学_第2页
第2页 / 共13页
计算机专业毕业设计论文外文翻译J2ME导学_第3页
第3页 / 共13页
资源描述:

《计算机专业毕业设计论文外文翻译J2ME导学》由会员分享,可在线阅读,更多相关《计算机专业毕业设计论文外文翻译J2ME导学(13页珍藏版)》请在装配图网上搜索。

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

2、rations. (Well 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 targeting a wide range o

3、f 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, allowing mobile wireless devices

4、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 JRE, J2ME is comprised of

5、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 profile defines the applicati

6、on; 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 and its Java virtual machine

7、. 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 - its just that they are shrunken versions of the J2SE JVM and are specific to J2ME.Configurations over

8、viewThe 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 Configuration (CLDC) is used specifically

9、 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 of view) than CDC. CLDC is also the co

10、nfiguration 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 used for 32-bit architectures requiring more t

11、han 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 configuration to define certain uses for devices. P

12、rofiles 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 own profile, the Foundation Profile, is availab

13、le 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 targetsTarget devices for J2ME applications developed u

14、sing 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 with limited bandwidth User interfaces with varying degrees of so

15、phistication; 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, target devices for CDC generally have the following characteristics: Power

16、ed 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 connectivity, often with a wireless, inconsistent connection and with limited bandwidth User interfaces with vary

17、ing degrees of sophistication; sometimes with no interface Some devices supported by CDC include residential gateways, smartphones and communicators, PDAs, organizers, home appliances, point-of-sale terminals, and car navigation systems. Developing j2me applicationsIntroductionIn this section, we wi

18、ll go over some considerations you need to keep in mind when developing applications for smaller devices. Well take a look at the way the compiler is invoked when using J2SE to compile J2ME applications. Finally, well explore packaging and deployment and the role preverification plays in this proces

19、s. 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 strategically design an application for a small device before you begin coding. Correcting the code because you failed to conside

20、r all of the gotchas before developing the application can be a painful process. Here are some design strategies to consider: Keep it simple. Remove unnecessary features, possibly making those features a separate, secondary application. Smaller is better. This consideration should be a no brainer fo

21、r all developers. Smaller applications use less memory on the device and require shorter installation times. Consider packaging your 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

22、 object types. Also, do not depend on the garbage collector. You should manage the memory efficiently yourself by setting object 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. Othe

23、r ways of reducing overall and peak memory use on small devices are to release resources quickly, reuse objects, and avoid exceptions.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

24、local variables than to access class members. Avoid string concatenation. String concatenation decreases performance and can increase the applications 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. Avoi

25、ding synchronization can increase performance as well. Separate the model using the model-view-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 deployin

26、g it. With J2ME, however, you use the J2SE compiler and need to invoke it with the appropriate 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 compilers CLASSPATH.

27、This approach will lead to run-time errors, because the compiler automatically searches 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, resulti

28、ng in run-time errors when you try to run your application. Packaging and deployment considerationsBecause 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 nec

29、essary to preverify your J2ME application before deployment. An additional check is made 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 comma

30、nd-line utility called preverify, which does the actual verification and inserts extra information 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 a

31、pplication must be packaged and deployed in a format suitable for the type of J2ME device, 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

32、by downloading and installing CLDC under Windows or UNIX. The current CLDC 1.0 release contains a CLDC implementation for Win32, Solaris, and Linux platforms. Well then install the KVM on your Palm hand-held device and look at compiling the Palm database development tools. Next, well show you how to

33、 download and install the Palm OS Emulator (POSE) and how to transfer a ROM image of a Palm device to your PC for use with the emulator. Finally, well look at downloading and installing the J2ME Wireless Toolkit, which is used for developing J2ME applications for MIDP devices. Downloading and instal

34、ling CLDC on Win32 or UNIXTo install CLDC and the Suns KVM software 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 wan

35、t to unzip the contents into the root directory, c:o Under UNIX, unzip 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 somet

36、hing like /usr/local or /opt.A new folder, j2me_cldc, is created beneath 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 ex

37、ample, c:j2me_cldc under Windows, or something like /usr/local/j2me_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. Inst

38、alling the Palm OS Emulator (POSE)The Palm OS Emulator (POSE) application 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 o

39、f this is only available for Windows. Although POSE also is available 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

40、OS Web site.2. Extract the contents of the zip file into its own directory.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

41、development environment to write and test MIDP applications. The download 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

42、 only. Windows 95 is not supported. Solaris and Linux versions of the 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 p

43、rogram to install the Wireless Toolkit. When you are prompted for the 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 d

44、evelopment, select Integrated setup in the Setup Type dialog.英文译文J2ME导学J2ME概览J2ME 是什么?Sun Microsystems 将 J2ME 定义为“一种以广泛的消费性产品为目标的的高度优化的 Java 运行时环境,包括寻呼机、移动电话、可视电话、数字机顶盒和汽车导航系统。”自从 1999 年 6 月在 JavaOne Developer Conference 上声明之后,J2ME 为小型设备带来了 Java 语言的跨平台功能,允许移动无线设备共享应用程序。有了 J2ME,Sun 已经使 Java 平台能够适应集成了

45、或基于小型计算设备的用户产品。 J2ME 总体架构J2ME 使用配置和简表定制 Java 运行时环境 (JRE)。作为一个完整的 JRE,J2ME 由配置和简表组成,配置决定了使用的 JVM,而简表通过添加特定于域的类来定义应用程序。 配置将基本运行时环境定义为一组核心类和一个运行在特定类型设备上的特定 JVM。简表定义应用程序;特别地,它向 J2ME 配置中添加特定于域的类,定义设备的某种作用。下图描述了不同的虚拟机、配置和简表之间的关系。它同时把 J2SE API 和它的 Java 虚拟机进行了比较。虽然 J2SE 虚拟机通常被称为一种 JVM,但是 J2ME 虚拟机、KVM 和 CVM

46、都是 JVM 的子集。KVM 和 CVM 均可被看作是一种 Java 虚拟机 - 它们是 J2SE JVM 的压缩版,并特定于 J2ME。 配置概述配置将基本运行时环境定义为一组核心类和一个运行在特定类型设备上的特定 JVM。虽然还可能在将来定义其他的配置,但当前 J2ME 存在两种配置: 连接限制设备配置 (CLDC) 特别与 KVM 一起用于内存有限的 16 位或 32 位设备。这是用于开发小型 J2ME 应用程序的配置(虚拟机)。(从开发的角度来看)它的大小限制让它比 CDC 更有趣、更具挑战性。CLDC 同时还是用于开发绘图工具应用程序的配置。 Palm 电脑便是一个运行小应用程序的小

47、型无线设备的示例。 连接设备配置 (CDC) 与 C 虚拟机 (CVM) 一起使用,用于要求内存超过 2 兆的 32 位体系结构。互联网电视机顶盒便是这类设备的一个示例。简表概述简表定义了您的应用程序所支持的设备类型。特别地,它向 J2ME 配置添加了特定于域的类来定义设备的某种作用。简表建立在配置的顶部。已经为 J2ME 定义了两种简表:KJava 和移动信息设备简表 (MIDP),它们也被建立在 CDLC 上。这两种简表适用于小型设备。 有一种纲要简表,您可以在它的上面创建自己的简表,这种纲要简表也称为基础表,可供 CDC 使用。然而,在本教程中,我们只重点介绍建立在 CLDC 顶部,适用

48、于小型设备的简表。 我们将在后面的章节中讨论上述这些简表,还会使用 KJava 和 MIDP 建立一些示例应用程序。 J2ME 目标设备使用 CLDC 开发的 J2ME 应用程序的目标设备通常具有以下特征: 可供 Java 平台使用的 160 到 512 千字节的总内存 功率有限,常常是电池供电 网络连通性,常常是无线的、不一致的连接并且带宽有限 用户接口混乱,程度参差不齐;有时根本就没有接口一些 CLDC 支持的设备,包括无线电话、寻呼机、主流个人数字助手 (PDA),以及小型零售支付终端。 依照 Sun Microsystems,CDC 的目标设备通常具有以下特征: 使用 32 位处理器

49、2 兆字节或更多可供 Java 平台使用的总内存 设备要求的 Java 2 “蓝皮书”虚拟机的全部功能 网络连通性,常常是无线的、不一致的连接并且带宽有限 用户接口混乱,程度参差不齐;有时根本就没有接口一些 CDC 支持的设备,包括常驻网关、智能电话和通讯器、PDA、管理器、家用电器、销售网点终端以及汽车导航系统。 开发J2ME应用程序介绍在这一章中,我们将复习一下在为小型设备开发应用程序时需要牢记的一些注意事项。我们将看一下在使用 J2SE 编译 J2ME 应用程序时调用编译器的方法。最后我们将探究打包和部署,以及在这个过程中提前验证所扮演的角色。 设计开发小型设备应用程序要注意的事项为小型

50、设备开发应用程序,需要您在设计阶段制定某种策略。最好是在开始编写代码之前,战略性地为小型设备设计应用程序。由于无法考虑到所有的 gotchas ,在开发应用程序之前更正代码是一件很痛苦的工作。 下面是一些可以考虑的设计策略: 保持程序简单。除去不必要的功能,如果可能的话,将它们做成独立的、次要的应用程序。 程序越小越好。这一点对所有的开发者来说应该是显而易见的。越小的程序占用的设备内存越少,并且花费的安装时间越少。可考虑将您的 Java 应用程序打包,作为压缩的 Java 档案 (jar) 文件。 运行时占用最少的内存。为 尽可能减少运行时占用的内存,使用标量类型代替对象类型。同时,不依赖垃圾

51、收集程序。您应该在使用完对象时将对象引用置空,这样可有效管理内存。另外一种 减少运行时所需内存的方法是使用“惰性”实例,它仅在必需时才分配对象。其它一些减少小型设备上过量和峰值内存使用的方法有快速释放资源、重新使用对象以 及避免异常。 性能注意事项为性能而编码。下面有一些以获得最优性能为目标的编码方法: 使用局部变量。访问局部变量比访问类成员更快。 避免字符串串联。字符串串联不仅会降低性能,而且会增加应用程序的内存峰值占用量。 使用线程,避免同步。任何运行时间超过 1/10 秒的操作都需要一个独立的线程。避免同步同样能提高性能。 使用模型视图控制器 (MVC) 分离模型。MVC 将代码中控制显

52、示的逻辑分离出来。 编译注意事项同其它的 Java 应用程序一样,您在打包和部署应用程序之前要先进行编译。尽管有了 J2ME,您仍然使用 J2SE 编译器并且需要用适当的选项来进行调用。特别的,您需要使用 -bootclasspath 选项来指示编译器使用 J2ME 类,而不是 J2SE 类。不要在编译器的 CLASSPATH 中设置配置类。这样将导致运行时错误,因为不管 CLASSPATH 中有什么,编译器将首先自动搜索 J2SE 的核心类。换句话说,编译器将无法引用特定 J2ME 配置中缺少的类或方法,结果导致在尝试运行应用程序时出现运行时错误。 打包和部署注意事项由于 J2ME 是为内存

53、有限的小型设备设计的。大部分常用的 Java 提前验证已经从虚拟机中除去以形成一个较小的覆盖区域。结果,在配置之前提前验证 J2ME 应用程序就很有必要。在运行时会附加一个检查以确保这个类在提前验证之后还没有改变过。 如何严格执行提前验证或者检查类的正确性依靠的是工具包。CLDC 提供一个称为提前验证的命令行实用程序,它能够进行实际的验证并且可以把一些额外的信息插入到类文件中去。MIDP 使用无线工具包,这种工具包提供一种 GUI 工具,也可从命令行运行这种工具。部署工作取决于您要部署的平台。应用程序必须以一种适合 J2ME 设备类型的格式进行打包和配置,就如简表定义的那样。 配置开发环境介绍

54、在这一章,我们将学习如何下载和安装开发 J2ME 应用程序必需的软件。现在就让我们开始吧,首先学习 Windows 或 UNIX 环境下下载和安装 CLDC。目前 CLDC 1.0 发行版包含 Win32、Solaris 和 Linux 平台上的 CLDC 执行。我们将在您的 Palm 设备上安装 KVM,然后学习如何编译 Palm 数据库开发工具。 下一步,您将学到如何下载和安装 Palm 操作系统仿真器 (POSE) 以及如何把 Palm 设备中的 ROM 映像传送到您的 PC 以便和仿真器一起使用。 最后,我们来看一看如何下载和安装 J2ME 无线工具包,该工具包可用来开发 MIDP 设

55、备的 J2ME 应用程序。 在 Win32 或 UNIX 中下载和安装 CLDC在 Windows 或 UNIX 平台上安装 CLDC 和 Sun 的 KVM 软件: 1. 下载CLDC。需要下载和安装的两个软件包为:j2me_cldc-1_0_2-fcs-winunix.zip 和 j2me_cldc-1_0_2-fcs-kjava_overlay.zip。2. 解压第一个软件包。 o 在 Windows 环境下,您可以把包里的内容解压至根目录 c: 下。o 在 UNIX 环境下,把内容解压至您喜欢的目录下。可以是主目录,但如果您为这台机器的所有用户安装的话,就把它安装在经常安装共享应用程序

56、文件的地方(例如,通常是类似 /usr/local 或 /opt 的目录。)在安装目录下,会创建一个新的文件夹 j2me_cldc,并且它还包含下列子目录:jam、docs、build、tools、api、kvm、samples 和 bin。3. 将第二个软件包解压至刚在 CLDC 安装过程中创建的 j2me_cldc 目录下。如:Windows 下的 c:j2me_cldc,或者 UNIX 下的 /usr/local/j2me_cldc 或 /opt/j2me_cldc。如果出现提示,则覆盖现有的所有文件。4. 把目录 j2me_cldc/bin 添加到 PATH 中,以免每次运行 CLDC

57、 程序 kvm 和提前验证时都要键入完全路径。安装 Palm 操作系统仿真器 (POSE)Palm 操作系统仿真器 (POSE) 应用程序软件仿真不同的 PDA 模型。仿真器允许在下载 PDA 应用程序到 PDA 之前,对它们进行开发、测试和调试。POSE 可从 Palm 操作系统仿真器 Web 站点上是免费获取。 它的二进制版本仅可用于 Windows。尽管 POSE 也可以在 UNIX 环境中运行,但您必须从 Palm OS Web 站点上下载源文件然后对它们进行编译,以适合您特定的 UNIX 平台。 在 Windows 下下载和安装 POSE: 1. 从Palm OS Web上下载 PO

58、SE 的最新压缩文件。2. 将压缩文件中的内容解压至自己的目录下。3. emulator.exe 文件现在已经在 POSE 的安装目录中了。当启动时,emulator.exe 就运行 Palm 操作系统仿真器。下载和安装 J2ME 无线工具包 (J2ME Wireless Toolkit)J2ME 无线工具包提供一个完整的开发环境来编写和测试 MIDP 应用程序。下载包括工具、文档和仿真环境,例如,一个与 Forte for Java 集成的模块。目前,J2ME 无线工具包仅支持 Windows 98 第二版、Windows NT 4.0 和 Windows 2000 是可用的,不支持 Windows 95。J2ME 无线工具包的 Solaris 和 Linux 版本在本教程编写的同时正处于筹划之中。在 Windows 环境下安装 J2ME 无线工具包请按如下步骤:1. 下载J2ME无线工具包2. 运行 j2me_wireless_toolkit-1_0_1-fcs.exe 安装无线工具包。当系统提示您提供安装目录时,请确保该安装目录的完全合法的路径中不包含任何空格。这将帮助您在今后使用工具包时避免可能出现的问题。如果您计划使用 Forte for Java 进行开发的话,在 Setup Type 对话框中选择 Integrated setup。

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!