Java technology is both a programming language and a platform.
1.1 The Java Programming Language
The Java programming language is a high-level language that can be characterized by all of the following buzzwords:
With most programming languages, you either compile or interpret a program so that you can run it on your computer. The Java programming language is unusual in that a program is both compiled and interpreted. With the compiler, first you translate a program into an intermediate language called Java bytecodes —the platform-independent codes interpreted by the interpreter on the Java platform. The interpreter parses and runs each Java bytecode instruction on the computer. Compilation happens just once; interpretation occurs each time the program is executed. The following figure illustrates how this works.
You can think of Java bytecodes as the machine code instructions for the Java Virtual Machine (Java VM). Every Java interpreter, whether it's a development tool or a Web browser that can run applets, is an implementation of the Java VM.
Java bytecodes help make "write once, run anywhere" possible. You can compile your program into bytecodes on any platform that has a Java compiler. The bytecodes can then be run on any implementation of the Java VM. That means that as long as a computer has a Java VM, the same program written in the Java programming language can run on Windows 2000, a Solaris workstation, or on an iMac.
1.2 The Java Platform
A platform is the hardware or software environment in which a program runs. We've already mentioned some of the most popular platforms like Windows 2000, Linux, Solaris, and MacOS. Most platforms can be described as a combination of the operating system and hardware. The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms.
The Java platform has two components:
• The Java Virtual Machine (Java VM)
• The Java Application Programming Interface (Java API)
You've already been introduced to the Java VM. It's the base for the Java platform and is ported onto various hardware-based platforms.
The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets. The Java API is grouped into libraries of related classes and interfaces; these libraries are known as packages. The following figure depicts a program that's running on the Java platform. As the figure shows, the Java API and the virtual machine insulate the program from the hardware.
Native code is code that after you compile it, the compiled code runs on a specific hardware platform. As a platform-independent environment, the Java platform can be a bit slower than native code. However, smart compilers, well-tuned interpreters, and just-in-time bytecode compilers can bring performance close to that of native code without threatening portability.
1.3 What Can Java Technology Do?
The most common types of programs written in the Java programming language are applets and applications. If you've surfed the Web, you're probably already familiar with applets. An applet is a program that adheres to certain conventions that allow it to run within a Java-enabled browser.
However, the Java programming language is not just for writing cute, entertaining applets for the Web. The general-purpose, high-level Java programming language is also a powerful software platform. Using the generous API, you can write many types of programs.
An application is a standalone program that runs directly on the Java platform. A special kind of application known as a server serves and supports clients on a network. Examples of servers are Web servers, proxy servers, mail servers, and print servers. Another specialized program is a servlet. A servlet can almost be thought of as an applet that runs on the server side. Java Servlets are a popular choice for building interactive web applications, replacing the use of CGI scripts. Servlets are similar to applets in that they are runtime extensions of applications. Instead of working in browsers, though, servlets run within Java Web servers, configuring or tailoring the server.
How does the API support all these kinds of programs? It does so with packages of software components that provide a wide range of functionality. Every full implementation of the Java platform gives you the following features:
The essentials: Objects, strings, threads, numbers, input and output, data structures, system properties, date and time, and so on.
• Applets: The set of conventions used by applets.
• Networking: URLs, TCP (Transmission Control Protocol), UDP (User Datagram Protocol) sockets, and IP (Internet Protocol) addresses.
• Internationalization: Help for writing programs that can be localized for users worldwide. Programs can automatically adapt to specific locales and be displayed in the appropriate language.
• Security: Both low level and high level, including electronic signatures, public and private key management, access control, and certificates.
• Software components: Known as JavaBeansTM, can plug into existing component architectures.
• Object serialization: Allows lightweight persistence and communication via Remote Method Invocation (RMI).
• Java Database Connectivity (JDBCTM): Provides uniform access to a wide range of relational databases.
2 : Java Technology in Embedded Devices
When Sun first introduced the Java programming language, it took the desktop computing world by storm. The simplicity and platform-independence of the language attracted developers who struggled with portability issues and project deadlines. Since that time, developers in the embedded device market have come to understand and appreciate the benefits of the Java platform Because of its many advantages, numerous device manufacturers now integrate the Java platform into consumer devices. In addition, vendors that build technology for the embedded device market are evolving the Java platform for the future, participating in the Java Community Process(JCP) Program.
2.1 Advantages of Java Technology for Embedded devices :
Today the market for embedded devices spans a wide variety of consumer and business products, including devices such as mobile phones, pagers, PDAs, set-top boxes, process controllers, office printers, and network routers and switches. Typically, embedded devices have dedicated functionality -- they are designed strictly for a specific set of tasks. Engineered for long life and high reliability, embedded devices incorporate low-speed microprocessors and may have a limited amount of memory.
To meet performance and size requirements, embedded device manufacturers will typically use a real-time operating system (RTOS) and custom, proprietary development tools, well-suited for meeting devices' memory limitations. There are numerous different RTOS vendors that exist today, each with a proprietary operating environment and many with tightly integrated and specialized development tools.
Early environments for embedded devices were developed in assembler. As these devices matured, some manufacturers shifted to higher-level languages like C and C++. Although using higher-level languages made it easier to find developers and staff new projects, the complexity of these languages continued to contribute to long schedules and high non-recurring engineering (NRE) costs. In addition, customers were constantly demanding new functionality in devices. As manufacturers responded by adding capabilities, more memory and software complexity was required. This raised manufacturing costs as well as increased NRE costs. Thus, embedded device manufacturers faced the constant challenge of managing increasing development costs.
To aggravate the problem, there were a greater number of target operating systems and processors, sometimes even within the same product families. Occasionally there were also new product categories and innovations, such as set-top boxes. Manufacturers faced intense competitive pressures, and were often required to put out more product in a shorter timeframe. As a result, manufacturers sought a more open, standards-based development environment -- one that would lower costs and speed development.
Embedded device manufacturers have turned to the Java programming language to answer their needs.
EmbeddedJava technology delivers a powerful means to standardize software development for embedded devices. By integrating a compact EmbeddedJava application environment directly into new devices, manufacturers can significantly decrease development costs and get their devices to market faster. Innovative EmbeddedJava tools condense the robust functionality of a Java application environment into a small memory footprint. In addition, EmbeddedJava technology provides device manufacturers with a rich software development environment, access to a wealth of standard development tools, and the economies of staffing from a large pool of development talent.
Java technology offers these advantages for embedded device manufacturers:
• Portability. Platform independence enables code reuse across processors and product lines, allowing device manufacturers to deploy the same applications to a range of target devices. This can provide manufacturers with a cost-effective way of developing a family of products with integrated applications.
• Rapid application development. Using the Java language offers more flexibility during the development cycle. Development can begin on a variety of available desktop environments, well before the targeted deployment hardware is available. There are many Java technology-based desktop development tools that can utilize components created for a variety of applications.
• Connectivity. The Java language provides a built-in framework for networking securely. Some software vendors offer off-the-shelf applications, such as browsers and email clients for Internet-connected devices.
• Simplified support and maintenance. With embedded Java technology, applications are easy to maintain, which provides greater longevity. There is excellent availability of training, consulting, and programming expertise.
• Reliability. Embedded devices require high reliability. The simplicity of the Java programming language - with its absence of pointers and its automatic garbage collection - eliminates many bugs and the risk of memory leaks. Because the language is based on a "sandbox" model, it confines the use of memory and system resources, contributing to greater reliability.
Portability. By using an underlying Java run-time environment, applications can be easily developed on a desktop system using standard software development tools. Hardware-specific code can be simulated on a desktop system, saving valuable development time. By taking into account the underlying target hardware characteristics, developers can then move applications with minimal effort to the specific target device.
Software reuse. Because the Java language is object-oriented and platform-independent, developers can migrate commonly used software modules -- or entire applications -- between products and across product lines.
Simplicity. The Java language is easy to learn and use. Unlike C++, the Java language features automatic memory management and a single inheritance model. Most importantly, the lack of pointers eliminates a common source of memory leaks.
Safety and security. The Java language provides a secure, isolated environment -- a "sandbox" -- in which applications can execute safely
Availability of developers. Today there is a huge talent pool of developers experienced with the Java programming language. The ready availability of developer talent helps keep development costs under control, enabling new projects to be staffed quickly. Training existing developers in the Java language can also help manufacturers retain valuable talent.
Longevity. Since the Java APIs have been developed with the involvement of many companies within the industry, the Java platform has gained a level of maturity that promises a long lifespan. This will simplify support and maintenance issues for device manufacturers concerned with long product life cycles.
2.2 Some Disadvantages :
Java's strong appeal for embedded applications is sometimes offset by concerns about its speed and its memory requirements. However, there are techniques that you can use to boost Java performance and reduce memory needs, and of course the Java virtual machine you choose affects Java performance, too. You can make better-informed decisions about using Java by understanding the factors that affect its performance and selecting meaningful benchmarks for embedded applications
3 : Why Java for embedded systems
Embedded or real-time systems include all those in which timing constrains imposed by the world outside of the computer play a critical role in the design and implementation of the system. Common areas for embedded systems are machine and process control, medical instruments, telephony, and data acquisition.
A primary source of input for embedded systems are random, short-lived, external signals. When such signals arrive, the processor must interrupt whatever else it is doing to capture the data, or it will be lost. Thus, an embedded program is most often organized as a set of individual, but cooperating threads of execution. Some threads capture new data, some analyze the new data and integrate it with past inputs, some generate the outgoing signals and displays that are the products of the system. Currently, most embedded programs are coded in C, with critical parts possibly in assembler.
Putting the issue of execution efficiency aside, some of the major problems of C for embedded systems are:
• The permissiveness of C operations, which can lead to undisciplined coding practices and ultimately to unstable execution.
• The absence of universal standards for multithreading, shared data protection, and intra-thread communication and coordination, which can make the program hard to transfer to alternate platforms. But, these are just the problems that Java solves. Since many programmers will have to learn Java because of its importance to the net, it will be natural for Java to supplant C in the embedded world.
The use of Java may be different, however. We anticipate that Java programs for embedded applications will differ from net applets in at least five major ways. Embedded applications will be:
• compiled into the native ISA for the target hardware.
• capable of running in the absence of a hard or floppy disk, and a network connection.
• supported by highly tailored, thus relatively small run-time packages.
• able to execute on multiple processors, if needed for capacity expansion.
• contain significant amounts of legacy C code, at least during the transition from C to Java.
• In most cases the embedded program that finally goes out into the field will have been compiled into native code. As a result, the program not need contain the Java interpreter and libraries of class code unless those classes are actually used by the application. The result is a smaller and faster program compared with the standard applet approach.
• Nevertheless, some embedded programs may benefit from retaining the capacity to dynamically load new Java source code. Those are applications that must be altered partially or totally while in the field. One example is a process control applications for which the process is changed from time to time to make alternate products.
4 : Embedded Java
ative to the Java PlatformDesigned to meet a wide spectrum of distributed, networked, and graphical application requirements, the Java platform provides a full set of classes that encompasses a broad range of functionality. These classes constitute a "core" Java platform for enterprise computing. The Java Community Process defines an all-inclusive method for the industry to expand the Java platform with added functionality by defining extension APIs, such as Java Media Framework or Java 3D APIs. This process offers developers a standardized way of implementing needed capabilities beyond what the core APIs provide.
• To meet the requirements of consumer devices (such as set-top boxes, smart phones, and hand-held devices like PDAs), the Personal Java Platform reimplements the full set of Java APIs defined by the Java application environment in order to fit into smaller devices with more limited memory configurations. The Personal Java platform also offers a graphics toolkit, the Truffle toolkit, created specifically for hand-held devices that all require general-purpose web-browsing.
4.1 The Embedded Java Application Environment
Unlike the Java and Personal Java platforms (which have required core APIs), the EmbeddedJava application environment allows for APIs to be configured relative to the requirements of an application. This allows EmbeddedJava technology to fit into the very limited memory footprints of embedded devices, including industrial controllers, process controllers, or scientific instruments.
4.2 EmbeddedJava Technology Relative to the Java Platform
Designed to meet a wide spectrum of distributed, networked, and graphical application requirements, the Java platform provides a full set of classes that encompasses a broad range of functionality. These classes constitute a "core" Java platform for enterprise computing. The Java Community Process defines an all-inclusive method for the industry to expand the Java platform with added functionality by defining extension APIs, such as Java Media Framework or Java 3D APIs. This process offers developers a standardized way of implementing needed capabilities beyond what the core APIs provide.
To meet the requirements of consumer devices (such as set-top boxes, smart phones, and hand-held devices like PDAs), the Personal Java Platform reimplements the full set of Java APIs defined by the Java application environment in order to fit into smaller devices with more limited memory configurations. The Personal Java platform also offers a graphics toolkit, the Truffle toolkit, created specifically for hand-held devices that all require general-purpose web-browsing.
The Embedded Java Specification allows any fields and methods from the core JDK 1.1.7 APIs (except java.applet) to be used in development. This allows developers to capitalize on the robust fullness of the Java APIs, but provides the flexibility to scale down and use only what is truly necessary. Sun provides optimizing tools to create the environment and convert the code into a condensed representation. Since applications are written in the Java language, software modules or entire applications can be migrated later to new platforms and easily reused, regardless of the underlying RTOS and target processor.
5. Application Development
5.1 The Process
Sun's advanced tools streamline the process of creating a compact EmbeddedJava application environment. The toolset has three primary components:
• This tool builds a list of the specific fields and methods used by the Java platform to run the Java application.
• JavaCodeCompact. Using the list provided from the JavaFilter tool, the JavaCodeCompact tool selects the fields and methods used by the application from the full set of Java classes. It then optimizes the code by removing unused parts of the platform, and produces a representation of the set of data structures.
• JavaDataCompact. This tool provides a means of linking in auxiliary data files such as HTML, image, and sound files.
To develop an EmbeddedJava application environment, the first step is to develop an application using any classes from the EmbeddedJava APIs. Next, the application and program classes are fed into the Java Filter tool. The Java Filter tool looks at the program elements required for the application and the operation of the JVM, and analyzes static interdependencies. Java Filter produces a list of the required classes, fields, and methods, which is then fed into JavaCodeCompact.
The JavaCodeCompact tool performs extensive optimizations to reduce the amount of RAM and ROM required by the application environment. This tool functions as a class preloader, creating the necessary internal data structures in advance, saving space by eliminating redundancies and resolving symbolic references. The JavaCodeCompact tool significantly reduces both the static memory and run-time memory requirements, producing a tightly compacted application environment in a platform-independent representation. If there are any associated data files (such as image or sound files), developers can then use the JavaDataCompact tool to convert them into the appropriate format. The JavaCodeCompact and JavaDataCompact tools produce data structure representations in C code, which allows these tools to represent run-time data structures in a platform-independent manner.
Finally, the data structure representations produced by the tools are compiled, along with any other native method code, using the native C compiler for the particular operating system and target device. The resulting object files are linked together to produce a small, compact EmbeddedJava executable image, which can then be placed into the device`s ROM (or placed on disk and later executed from the device's RAM).
This process -- and the efficiency of the EmbeddedJava tools -- enables device manufacturers to configure and build highly optimized Java application environments for devices with small memory footprints.
1.2 Special hardware for embedded applications
1.3
Java programs currently execute on PCs or workstations, which of course have a hard disk. Thus, the Java interpreter expects to be able to load any needed class libraries and code components from a disk.
In contrast, many embedded systems are housed within a highly-constrained box, and have to operate in the harsh factory floor environment. Lack of space, power or cooling, or excessive vibration may preclude a standard hard or floppy disk As a result, we anticipate that embedded applications will be structured as a small section of initialization code that starts the Java programs from a ROM disk. (A ROM disk behaves like a hard disk, but uses read-only-memory as the medium.) Any needed temporary data files will be stored in RAM disks.
Java applets may be called upon to give voice to sound files and sight to arbitrary still or moving picture files. Thus, the Java runtime operating system must provide hardware support for a wide variety of potential audio-visual operations. The Java applet environment places open-ended requirements on its OS.
Embedded applications are generally not so free wheeling; by the time the application is ready for the field, the OS requirements and hardware environment should be known. Thus, the OS needed for an embedded Java applications can be tailored to that specific application, by including only what is known to be needed. The saving in memory size and maintenance effort can be enormous.
5.3 Memory Requirements
Study determined that the average memory requirement of a program written in Java is two to three times greater than for one written in C/C++. Even the compact nature of bytecode, usually about 50 percent smaller than compiled C/C++ machine code, can't offset that overhead. Recognizing that trying to drop Java in its original, desktop-oriented form into embedded systems won't work, Sun Microsystems, Java's originator, took the language through several evolutionary steps in an effort to tailor it to the embedded environment. Today, the Java 2 Platform, Micro Edition (J2ME), represents the latest, most evolved, and slimmest version of Java for the embedded space.
You can trim J2ME by eliminating classes and code components that aren't needed for your application. The JVM, native libraries, core classes, and application bytecode go into ROM. JVMs for embedded applications generally run under 500 kB, whereas class libraries for J2ME typically don't exceed 1.5 MB. Java components that affect RAM requirements include the JVM (for bytecode execution), the potential dynamic compiler, the Java heap, and the number of threads (the latter two obviously depend on the application). Executing as much of the application as possible using an interpreter -- while maintaining acceptable execution performance -- helps contain the memory footprint.
5.4 : Choosing the Right Java Platform
Of course, your choice of JVM is one key to optimizing Java performance for your application. Obviously, you need a JVM designed for embedded applications.
Embedded JVMs are highly user-configurable to match different embedded system requirements, but which embedded JVM should you use? Java benchmarks are meant to help you evaluate JVMs and Java performance, but you need to be careful about which ones you use and about the conclusions you draw from them. A good benchmark score for a particular JVM doesn't necessarily mean that using it will make your application go faster.
Consequently, before evaluating a JVM, you have to evaluate any benchmark to determine how meaningful it may be to your application, taking into account the whole Java environment that's associated with it. Some benchmarks are very application-specific and may not apply to the kind of Java applications you're developing. Additionally, because JVM vendors commonly optimize their products to achieve good benchmark scores, the scores can be misleading about how much a given JVM will improve the performance of your particular application. Conversely, if your application has specific problems in certain areas, an environment that's optimized to improve general processing won't solve those specific processing problems
6 : The Embedded Java TM API
The Embedded Java TM API is derived from the JDK 1.1 API . The EmbeddedJava platform addresses the software needs of dedicated-purpose embedded devices.
6.1 Facilities Provided by Embedded Java platform to applications :
It is not a standalone specification because it is based on the JDK 1.1 API. Java APIs introduced after JDK 1.1 will not automatically become a part of the EmbeddedJava API. New Java APIs will be reviewed and evaluated for appropriateness before being added to the Embedded Java platform.
The EmbeddedJava API is derived from the JDK 1.1 API. The following definitions describe the degree of API support provided by the EmbeddedJava platform.
Configurable
All of the package's methods and fields are available to an EmbeddedJava application. Java Filter determines the list of methods and fields that are required by the Embedded Java application. The EmbeddedJava development environment then builds an Embedded Java application environment that supports the specific needs of the Embedded Java application.
Unsupported
The feature is not supported by the EmbeddedJava platform. None of the classes, methods or fields from the package may be made available to an EmbeddedJava application.
6.2 Java Standard Extensions
The EmbeddedJava platform supports Java standard extensions that are based on JDK 1.1. Java standard extensions have package names that begin with javax. Java standard extensions that are supported by the EmbeddedJava
platform are configurable.
7.3 EmbeddedJava API Support
The table below describes the EmbeddedJava API by listing the packages available in the JDK 1.1 API and indicating how the EmbeddedJava platform supports each package.
Package Support
7 :Conclusion
Embedded Java technology will continue to evolve as it is integrated with other technologies. In addition, the industry will define standard extensions to the Java APIs as need dictates, including an extension API that will support real time capability. A real-time extension API will allow future real-time applications to be written entirely in the Java programming language.
Subscribe to:
Post Comments (Atom)
I really liked your blog article. Great.
ReplyDeletecore java online training
java online training hyderabad