by Guowei Huang
Java is a powerful language that has exhibited its success by turning static Web pages into interactive, dynamic, animated documents bolstered by distributed, platform-independent applications. Since its debut, it has taken the market by storm and filled the World Wed Web browers almost everywhere with animation, audio, and real-time interactivity.
In this presentatioin we will provide some interesting facts about Java's development, introduce the basic and main features of the language, and give an overview of JavaOS -- a small and efficient operating environment developed by JavaSoft that executes Java applications dirctly on hard ware platforms without requiring a host operating system.
The most important simplification is that Java does not use pointers (one of the most bug-prone aspects of C and C++ programming language) and implements automatic garbage collection so that we don't need to worry about dangling pointers, invalid pointer references, and memory leaks and memory management.
This means that the programmer focus on the data in his application and the interface to it. As compared to C++, Java is more strict in terms of the object-oriented nature. In Java, everything must be done via method invocation for a Java object.
Java supports various levels of network connectivity through classes in java.net.
Java puts a lot of emphasis on early checking for possible problems, later dynamic (runtime) checking, and eliminating situations that are error prone: strongly-typedness, byte-code verification, removal of pointers, and automatic garbage collection.
Java implements several security mechanisms to protect you against malicious code that might try to invade your file system. This includes the removal of pointers and byte-code verification.
Java program are compiled to an architecture neutral byte-code format. Java application can run on any system that implements the Java Virtual Machine.
The portability actually comes from architecture-neutrality. But Java goes even more by explicitly specifying the size of each of the primitive data types to eliminate implementation-dependence.
The Java compiler generates byte-codes. The Java interpreter execute the translated bytecodes directly on system that implements the Java Virtual Machine.
Compared to those high-level, fully-interpreted scripting languages, Java is high-performance. If the just-in-time compilers are used or run of system supported by JavaOS, performance will be as good as r better than that of native C or C++.
Java provides support for multiple threads of execution that can handle different tasks with a Thread class in the java.lang Package. The thread class supports methods to start a thread, run a thread, stop a thread, and check on the status of a thread .
Java loads in classes as they are needed, even from across a network. This makes an upgrade to software much easier and effectively.
The default Java environment currently consists of several different Java packages implementing a diverse set of fundamental classes. They include the following:
The java.lang package contains the basic java classes and native types: Class, Object, Boolean, Float, Double, Integer, String, and so on plus those dealing with the extended capabilities of the language and connection with the rest of the system environment.
The java.awt package is the abstract Windowing Toolkit which allows you to deal with GUI objects in a generic manner without regard to the system on which your program in running. The classes of this package may be roughly divided into three categories:
The java.applet package contains the Applet class, which is the superclass of all applets.
The java.io package contains classes to support reading and writing streams, files, and pipes. These classes form a fairly structured hierarchy -- most of them are subclasses of InputStream or OutputStream.
The java.net package contains class to support network programming. These include dealing with sockets, Internet addresses, network datagrams, uniform resource locators (URLs), and content handlers for data from a URL.
The java.util contains general-purpose utility classes for data structures, such as dictionaries, hashtables, dates, stacks, bits, and strings.
Java has many language features that lead to more robust programs with less coding. These include OOP classes, garbage collection, C syntax, uniform data sizes, boolean and string types, exception handling, final cause, labeled break and continue, strong typing, array boundary checking. The philosophy of using computing power to achieve better program reliability is well-established in Java.
With all the hype around Java, we also hear some discrepancies on what Java has achieved. Here are some issues we would like to discuss.
Certain aspects of Java are easier to learn than C++, but the difficulties most people have in learning to program in both C++ and Java have little to do with the language itself. Instead, that have to do with fundamental object-oriented concepts. Java is somewhat easier than C or C++ not because its syntax is any simpler, but more because there are fewer surprises.
Java source code is more portable than C-based languages. Java avoids the major source of porting problems by defining the size of basic types for all implementations.
(Some people points out the while storage requirements for float and double are defined by Java, precision during calculation is not. This means that that a program that uses floating point arithmetic can produce different answers on different systems, with the degree of difference increasing with the number of calculations a particular value goes through.)
Java is more portable than other languages in its object code. The trade off is in performance.
Due to its portable byte code, the same Java applet will run anywhere the Java Virtual Machine runs. But Java doesn't solve all the problems of cross-platform development.
Theoretically Java may be perfectly suitable for big project. But we should also consider the following factor:
The larger of a applications, the more severe these factors will affect the performance.
For a lot of reasons, Java is likely to always be slower than C++ and Fortran for typical application. Some of these reasons are:
With the growing popularity, the issue of performance is becoming more and more important. We hope that with the coming of JavaOS -- a new operating environment, there will be a huge improvement in performance for Java applications.
JavaOS is a small and efficient operating environment developed by JavaSoft that allowsJava applications to run directly on hardware platforms without requiring a host operating system. The goal of JavaOS is to enable the development of secure, high performance, and highly robust intelligent and dynamic network devices built on multiple hardware platforms in heterogeneous, distributed networks. JavaOS is currently targeted at systems such as intranet terminals for enterprise desktops, consumer Internet computers suitable for Web surfing, and embedded devices where hardware resources are even more restricted. For example, devices have only 1 or 2 MB of RAM and 1 or 2MB of ROM, set-top boxes, PDA's and even electronic devices without any graphical display. One of the best ways of reducing a device's hardware requirements is to remove the overhead caused by requiring a host operating system.
The Java Platform can be provided in many environments by embedding the Java Virtual Machine and foundation classes within an application, like a Web browser, or embedding them within an operating system. Both of these methods rely on the support of a host operating system
Figure 1 illustrates the software architecture used when running Java programs on a conventional operating system.
Each of the major features provided in the Java Platform directly or indirectly places requirements on host operating system. One must perform the following tasks to match the Java run-time and classes to particular host operating system:
In order to meet the goal of providing Java Platform without a host operating system, we had to perform the following tasks:
Figure 2 shows a high-level view of the JavaOS architecture.
JavaOS differs from conventional operating systems in several ways: it does not need a file system, does not need virtual memory, does not need separate address spaces, does not support more than one programming language, and does not have its own set of system calls calls.
JavaOS resembles an operating system in several ways: it is bootable, supports a password-protected login feature, safely runs several applets at a time, includes several device drivers, communicates using many standard network protocols, has its own window system, has an API--the Java API, and will run the thousands of applets and applications that have been written.
With little performance tuning and minimal use of native methods, the first measurements and benchmarks indicate that performance is not only better than expected but also better than some more mature systems written in C or C++.
The TCP/IP throughput on Java OS is already double Sun's original goal and far more than adequate for Web browsing. Encouraging results have been observed by running Pendragon Software's CaffeineMark benchmark on several systems to compare their performance when executing Java applets.
These good results come from the removal of the many layers of software architecture that other operating systems have built up to make programming in languages like C safer and less platform-dependent.
A complete JavaOS needs a total of 4MB of ROM and 4MB of RAM. The minimal memory for JavaOS in its smallest possible configuration will be about 128K of RAM and 512K of ROM. This minimal memory requirement does not include addition memory that would be needed for applications.
The current JavaOS runs on two sets of platforms: platforms based on SPARC microprocessors and platforms based on microprocessors compatible with Intel's x86 instruction set.
The following advantages of using JavaOS are claimed in JavaSoft's white paper about JavaOS.
The Java programming language and environment is designed to solve a number of problems in modern programming practice. It has many interesting features that make it an incredibly powerful language. Since its debut, it has taken the market by storm. Surrounded by all the hype about Java it may be advisable to watch rather than to predict how Java's strength and weakness will affect its future. So far, Java is doing unbelievably good in terms of market and development of its environment. We already have Java JDBC, Java WorkShop, Java Beans. Now we have JavaOS, Java Electronic Commerce Framework (JECF), Microsoft Visual J++. Performance will be a big issue as Java grows and great improvement can be expected. But it is still too early to tell Java's future. Let us watch.