Sie sind auf Seite 1von 11

PSS, MIG-250, Kanan Vihar, Phase-2, Patia, Bhubaneswar, Tel:2725404

History of JAVA
Early history

Duke, Java's mascotThe Java platform and language began as an internal project at Sun Microsystems in
December of 1990. Engineer Patrick Naughton had become increasingly frustrated with the state of Sun's C++ and
C APIs (application programming interfaces) and tools. While considering moving to NeXT, Naughton was offered a
chance to work on new technology and thus the Stealth Project was started.

The Stealth Project was soon renamed to the Green Project with James Gosling and Mike Sheridan joining
Naughton. Together with other engineers, they began work in a small office on Sand Hill Road in Menlo Park,
California. They were attempting to develop a new technology for programming next generation smart appliances,
which Sun expected to be a major new opportunity.

The team originally considered using C++, but it was rejected for several reasons. Because they were developing
an embedded system with limited resources, they decided that C++ demanded too large a footprint and that its
complexity led to developer errors. The language's lack of garbage collection meant that programmers had to
manually manage system memory, a challenging and error-prone task. The team was also troubled by the
language's lack of portable facilities for security, distributed programming, and threading. Finally, they wanted a
platform that could be easily ported to all types of devices.

Bill Joy had envisioned a new language combining the best of Mesa and C. In a paper called Further, he proposed
to Sun that its engineers should produce an object-oriented environment based on C++. Initially, Gosling attempted
to modify and extend C++, which he referred to as C++ ++ -- , but soon abandoned that in favor of creating an
entirely new language, which he called Oak after the tree that stood just outside his office.

The team worked long hours and by the summer of 1992, they were able to demonstrate portions of the new
platform including the Green OS, the Oak language, the libraries, and the hardware. Their first attempt,
demonstrated on September 3, 1992, focused on building a PDA device named Star7[1] which had a graphical
interface and a smart agent called "Duke" to assist the user. In November of that year, the Green Project was spun
off to become FirstPerson, Inc, a wholly owned subsidiary of Sun Microsystems, and the team relocated to Palo
Alto. The FirstPerson team was interested in building ighly interactive devices, and when Time Warner issued an
RFP for a set-top box, FirstPerson changed their target and responded with a proposal for a set-top box platform.
However, the cable industry felt that their platform gave too much control to the user and FirstPerson lost their bid to
SGI. An additional deal with The 3DO Company for a set-top box also failed to materialize. Unable to generate
interest within the TV industry, the company was rolled back into Sun.

Java meets the Internet

In June and July of 1994, after a three-day brainstorming session with John Gage, James Gosling, Joy, Naughton,
Wayne Rosing, and Eric Schmidt, the team re-targeted the platform for the Web. They felt that with the advent of
the Mosaic browser, the Internet was on its way to evolving into the same highly interactive medium that they had
envisioned for cable TV. As a prototype, Naughton wrote a small web browser, WebRunner, later renamed HotJava.

That year, the language was renamed Java after a trademark search revealed that the name "Oak" was used by a
manufacturer of video adaptor cards. The name Java was coined at a local coffee shop frequented by some of the
members. It is not clear whether the name is an acronym or not; although some accounts claim that it stands for the
names of James Gosling, Arthur Van Hoff, and Andy Bechtolsheim, or Just Another Vague Acronym, it is generally
accepted that "Java" does not stand for anything. Lending credence to the idea that Java owes its name to the
products sold at the coffee shop is the fact that the first 4 bytes (the so-called "Magic number") of any class file are,
in hexadecimal, 0xCAFEBABE. In October of 1994, HotJava and the Java platform was demonstrated for Sun
executives. Java 1.0a was made available for download in 1994, but the first public release of Java and the HotJava
web browser came on May 23, 1995, at the SunWorld conference. The announcement was made by John Gage,
the Director of Science for Sun Microsystems. His announcement was accompanied by a surprise announcement
by Marc Andreessen, Executive Vice President of Netscape, that Netscape would be including Java support in its
browsers. On January 9th, 1996, the JavaSoft business group was formed by Sun Microsystems to develop the
technology.[2] Two weeks later the first version of Java was released.

Recent history
PSS, MIG-250, Kanan Vihar, Phase-2, Patia, Bhubaneswar, Tel:2725404

After several years of popularity, Java's place in the browser has steadily eroded. For simple interactive animations,
it has been almost completely superseded by Macromedia Flash and Shockwave. As of 2005 its use is mostly
limited to more complex applications like Yahoo! Games. It has also suffered from a lack of support by Microsoft
which no longer includes the Java platform with Internet Explorer or Windows.

By contrast, on the server side of the Web, Java is more popular than ever, with many websites using JavaServer
Pages and other Java-based technologies.

On the desktop, stand-alone Java applications remain relatively rare because of their large overhead. However, with
the great advances in computer power in the last decade along with improvements in VM and compiler quality,
several have gained widespread use, including the NetBeans and Eclipse Integrated development environments,
and file sharing clients such as Limewire and Azureus. Java is also used in the Matlab mathematics program for
rendering the user interface and for part of the calculation functionality. Java Swing desktop applications are being
developed as an alternative to Microsoft .NET technology.

Version history

Java Web Start, first introduced for J2SE 1.3, allows provisioning applications over the Web by clicking a desktop
icon or a link on a website.The Java language has undergone several changes since JDK (Java Development Kit)
1.0 as well as numerous additions of classes and packages to the standard library. Since J2SE 1.4, the evolution of
the Java Language has been governed by the Java Community Process (JCP), which uses Java Specification
Requests (JSRs) to proposed and specify additions and changes to the Java platform. The language is specified by
the Java Language Specification (JLS); changes to the JLS are managed under JSR 901.

JDK 1.0 (January 23, 1996) — Initial release


JDK 1.1 (February 19, 1997) — Major additions includedan extensive retooling of the AWT event model
inner classes added to the language, JavaBeans, JDBC, RMI

J2SE 1.2 (December 8, 1998) —This and subsequent releases through J2SE 5.0 were rebranded Java 2 and the
version name "J2SE" (Java 2 Platform, Standard Edition) replaced JDK to distinguish the base platform from J2EE
(Java 2 Platform, Enterprise Edition) and J2ME (Java 2 Platform, Micro Edition). Major additions included: [press
release] strictfp keyword reflection the Swing graphical API was integrated into the core classes Sun's JVM was
equipped with a JIT compiler for the first time Java Plug-in Java IDL, an IDL implementation for CORBA
interoperability Collections framework

J2SE 1.3 (May 8, 2000) - The most notable changes were


HotSpot JVM included (the HotSpot JVM was first released in April, 1999 for the J2SE 1.2 JVM)
RMI was changed to be based on CORBA, JavaSound, Java Naming and Directory Interface (JNDI) included in
core libraries (previously available as an extension), Java Platform Debugger Architecture (JPDA)

J2SE 1.4 (February 6, 2002) —This was the first release of the Java platform developed under the Java
Community Process as JSR 59. Major changes included:
assert keyword (Specified in JSR 41.) regular expressions modeled after Perl regular expressions
exception chaining allows an exception to encapsulate original lower-level exception non-blocking NIO (New
Input/Output) (Specified in JSR 51.)
logging API (Specified in JSR 47.)
image I/O API for reading and writing images in formats like JPEG and PNG
integrated XML parser and XSLT processor (JAXP) (Specified in JSR 5 and JSR 63.)
integrated security and cryptography extensions (JCE, JSSE, JAAS)
Java Web Start included (Java Web Start was first released in March, 2001 for J2SE 1.3) (Specified in JSR 56.)

J2SE 5.0 (September 30, 2004) — (Originally numbered 1.5, which is still used as the internal version number.[3])
Developed under JSR 176, Tiger added a number of significant new language features:
Generics — provides compile-time (static) type safety for collections and eliminates the need for most typecasts.
(Specified by JSR 14.)
Metadata — also called annotations, allows language constructs such as classes and methods to be tagged with
additional data, which can then be processed by metadata-aware utilities. (Specified by JSR 175.)
Autoboxing/unboxing — automatic conversions between primitive types (such as int) and primitive wrapper classes
PSS, MIG-250, Kanan Vihar, Phase-2, Patia, Bhubaneswar, Tel:2725404
(such as Integer). (Specified by JSR 201.)
Enumerations — the enum keyword creates a typesafe, ordered list of values (such as Day.MONDAY,
Day.TUESDAY, etc.). Previously this could only be achieved by non-typesafe constant integers or manually
constructed classes (typesafe enum pattern). (Specified by JSR 201.)
Enhanced for loop—the for loop syntax is extended with special syntax for iterating over each member of any
Iterable, such as an array or Collection, using a construct of the form:
void displayWidgets (Iterable<Widget> widgets) {
for (Widget w : widgets) {
w.display();
}}
This example iterates over the Iterable object widgets, assigning each of its items in turn to the variable w, and then
calling the Widget method display() for each item. (Specified by JSR 201.)

Java SE 6 —As of 2006 this is currently in development under JSR 270. A beta version was released on February
15, 2006 [press release] and is available at http://java.sun.com/javase/6/. Another beta is expected summer 2006
with the final release in autumn 2006. New builds including enhancements and bug fixes are released
approximately weekly. As of this version, Sun replaced the name "J2SE" with Java SE and dropped the ".0" from
the version number.[4]

Java SE 7 —As of 2006, this is in the early planning stages. Development is expected to begin in spring 2006,
with release estimated in 2008.[5]
In addition to the language changes, much more dramatic changes have been made to the Java class library over
the years, which has grown from a few hundred classes in JDK 1.0 to over three thousand in J2SE 5.0. Entire new
APIs, such as Swing and Java2D, have been introduced, and many of the original JDK 1.0 classes and methods
have been deprecated.

Java's Versions

Java has had several releases in its early years and the language has quickly grown in size:

Version # classes # packages Released Comment

1.0 212 8 Jan 1996

1.1 504 23 Feb 1997

1.2 1520 59 Dec 1998 Also called "Java 2, Release 1.2"

1.3 1840 76 May 2000 Also called "Java 2, Release 1.3,Standard


Edition". Version 1.3 focused on speed improvements , while adding enhancements is fewer than
previous releases.

Since its introduction, Sun has released a new version of the Java language every two years or so.
These new versions brought enhancements, new capabilities and fixes to bugs. Until recently, the
versions were numbered 1.x, where x reached up till 4. (Intermediate revisions were labeled with a third
number - 1.x.y - as in 1.4.2.) The newest version, however, is called Java 5.0 rather than Java 1.5.

Below is a timeline of the different versions of the basic, or Standard Edition (SE), of Java along with
some of the new features that each one introduced. This edition contains the core language packages
(the name for code libraries in Java) and is aimed for desktop programming.

Version 1.0 of the Java Development Kit (JDK) was released for free by Sun.

• 8 packages with 212 classes


• Netscape 2.0-4.0 included Java 1.0.
• Microsoft and other companies licensed Java.

Version 1.1
PSS, MIG-250, Kanan Vihar, Phase-2, Patia, Bhubaneswar, Tel:2725404
• 23 packages - 504 classes
• Improvements include better event handling, inner classes, improved JVM.
• Microsoft developed its own 1.1. compatible Java Virtual Machine for the Internet Explorer.
• Many browsers in use are still compatible only with 1.1.
• Swing packages of greatly improved graphics became available during this time but not included
with the core language.

Version 1.2, also called the Java 2 Platform

• 59 packages - 1520 classes


• Code and tools distributed as The Software Development Kit (SDK)
• Java Foundation Classes (JFC), based on Swing, for improved graphics and user interfaces, now
included with the core language.
• Collections API included support for various lists, sets, and hash maps.

Version 1.3:

• 76 packages - 1842 classes


• Performance enhancements including the Hotspot virtual machine.

Version 1.4:

• 135 packages - 2991 classes


• Improved IO, XML support, etc.

Version 5.0 (previously numbered 1.5):

• 165 packages, over 3000 classes


• Faster startup and smaller memory footprint
• Metadata
• Formatted output
• Generics
• Improved multithreading features

Java's Editions

In mid-1999, Sun defined three editions for Java:

• Java Standard Edition (J2SE): the core Java language (previously just called "Java").Java
Platform, Standard Edition (Java SE, formerly known as J2SE) offers a complete environment for
application development and deployment on desktops and servers. Java SE is also at home in today's
demanding Embedded and Real-Time environments. Java SE includes classes that
support the development of Java Web Services and provides the foundation for Java Platform,
Enterprise Edition (Java EE). There are two principal products in the Java Platform, Standard
Edition (Java SE, formerly known as J2SE) family: Java SE Runtime Environment (JRE) and Java SE
Development Kit (JDK). The JRE provides the Java APIs, Java virtual machine, and other components
necessary to run applets and applications written in the Java programming language. It is also the
foundation for the technologies in the Java Platform, Enterprise Edition (Java EE) for enterprise software
development and deployment. The JRE does not contain tools and utilities such as compilers or debuggers
for developing applets and applications.

The JDK is a superset of the JRE, and contains everything that is in the JRE, plus tools such as
the compilers and debuggers necessary for developing applets and applications.

• Java Enterprise Edition (J2EE): which addresses using Java in the middle tier of large
Enterprise Web applications.With the Java 2 Platform came a separate version with enhanced
PSS, MIG-250, Kanan Vihar, Phase-2, Patia, Bhubaneswar, Tel:2725404
resources targeted at enterprise applications. The Java 2 Enterprise Edition now provides a wide
array of tools for building middleware software such as for database access applications, online
storefronts, and other services

• Java Micro Edition (J2ME): as Java grew in size (to address requirements for large business
applications), it became necessary to define a smaller edition with the "key" language features
that were required to run software on small or embedded devices. Sun created the Java 2 Micro
Edition (J2ME) to allow development of Java applications for devices that do not have the same
processing power and memory found on a typical desktop platform. This includes cellular phones, PDAs,
pagers, entertainment and automotive navigation systems, to name a few. Read here to learn about
J2ME's configurations, application programming interfaces, and device profiles.

In the late 1990s, Sun split off two other more specialized branches, or editions, of Java. One is
aimed at small, embedded applications and the other for large scale middleware applications:

Micro Java

Embedded systems such as cell phones and device controllers typically offer reduced resources
as compared to desktop PCs. This means substantially less disk space or no disk at all, and less
of other types of nonvolatile memory. It also usually means a smaller display or perhaps no display at all.

For such systems Sun offers slimmed down versions of Java.

• JavaCard - extremely limited Java for systems with only 16kb nonvolatile memory and
512 bytes volatile

• EmbeddedJava - based on Java 1.1 for 32 bit system with about 512kb each for ROM and
RAM. Individual packages, classes and even methods in the core language can be thrown out to
make room.

• PersonalJava - based on Java 1.1.8 for larger systems with 2MB ROM and more than
1MB RAM.

• Java 2 Platform, Micro Edition (J2ME) - based on the Java 2 Platform, J2ME replaces
the Java 1.1 based systems (EmbeddedJava and PersonalJava but not JavaCard). The
developer will choose from different configurations to suit the capacity of a given system.

Naming Conventions

All of these editions and version numbers can be a bit confusing for newcomers. Also, terms change
such as Java Development Kit becoming Software Development Kit. For this course, however, you can
just use the latest version - Java 5.0 - and not worry about all these historical issues.

Note that we use the terms Java 1.x, SDK 1.x, and J2SE 1.x interchangeably and similarly, for Java 5.0,
SDK 5.0, and J2SE 5.0. This course was originally developed with Java 1.4.2 but we have now
converted the codes to Java 5.0.

We also will occasionally refer simply to the "platform" to indicate the whole Java progamming
environment provided by the compiler, JVM, and the various other tools available for working with the
language.

Introduction to Java

Java is an object-oriented programming language with a built-in application programming interface (API) that can
handle graphics and user interfaces and that can be used to create applications or applets. Because of its rich set of
API's, similar to Macintosh and Windows, and its platform independence, Java can also be thought of as a platform
in itself. Java also has standard libraries for doing mathematics.
PSS, MIG-250, Kanan Vihar, Phase-2, Patia, Bhubaneswar, Tel:2725404
Much of the syntax of Java is the same as C and C++. One major difference is that Java does not have pointers.
However, the biggest difference is that you must write object oriented code in Java. Procedural pieces of code can
only be embedded in objects. In the following we assume that the reader has some familiarity with a programming
language. In particular, some familiarity with the syntax of C/C++ is useful.

In Java we distinguish between applications, which are programs that perform the same functions as those written
in other programming languages, and applets, which are programs that can be embedded in a Web page and
accessed over the Internet. Our initial focus will be on writing applications. When a program is compiled, a byte
code is produced that can be read and executed by any platform that can run Java.

The Java programming language is robust and versatile, enabling developers to:

• Write software on one platform and run it on another.


• Create programs to run within a web browser.
• Develop server-side applications for online forums, stores, polls, processing HTML forms, and
more.
• Write applications for cell phones, two-way pagers, and other consumer devices.

It's no wonder the Java platform attracts so many new developers.

Why Java's Cool

Java has caused more excitement than any development on the Internet since Mosaic. Everyone, it seems, is
talking about it. Unfortunately very few people seem to know anything about it. This tutorial is designed to change
that.

People are excited about Java because of what it lets them do. Java was the first way to include inline sound and
animation in a web page. Java also lets users interact with a web page. Instead of just reading it and perhaps filling
out a form, users can now play games, calculate spreadsheets, chat in realtime, get continuously updated data and
much, much more.

Here are just a few of the many things Java can do for a web page:

• Inline sounds that play in realtime whenever a user loads a page


• Music that plays in the background on a page
• Cartoon style animations
• Realtime video
• Multiplayer interactive games

However Java is more than just a web browser with special features. All of these features can be integrated into
browsers in other ways. Although HotJava was the first browser to include inline sound and animation, Microsoft's
Internet Explorer 2.0 and Netscape Navigator 2.0 support these features in several different ways. What makes
Java special? Java is a programming language for distributed applications. It doesn't just allow you to add new
types of content to your pages like Netscape and Internet Explorer do. Rather it lets you add both the content and
the code necessary
to interact with that content. You no longer need to wait for the next release of a browser that supports your
preferred image format or special game protocol. With Java you send browsers both the content and the program
necessary to view this content at the same time! Let's think about what this means for a minute. Previously you had
to wait for all the companies that make the web browsers your readers use to update their browsers before you
could use a new content type. Then you had to hope that all your readers actually did update their browsers. Java
compatibility is a feature that any browser can implement and by so doing implement every feature! For instance
let's say you want to use EPS files on your Web site. Previously you had to wait until at least one web browser
implemented EPS support. Now you don't wait. Instead you can write your own code to view EPS files and send it
to any client that requests your page at the same time they request the EPS file.

Or suppose you want people to be able to search your electronic card catalog. However the card catalog database
exists on a mainframe system that doesn't speak HTTP. Before Java you could hope that some browser
implemented your proprietary card catalog protocol; (fat chance) or you could try to program some intermediate cgi-
PSS, MIG-250, Kanan Vihar, Phase-2, Patia, Bhubaneswar, Tel:2725404
bin on a UNIX box that can speak HTTP and talk to the card catalog, not an easy task. With Java when a client
wants to talk to your card catalog you can send them the code they need to do so. You don't have to try to force
things through an httpd server on port 80 that were never meant to go through it.

If that were all Java was, it would still be more interesting than a <marquee> or <frame> tag in some new browser
beta. But there's a lot more. Java is platform independent. A Java program can run equally well on any architecture
that has a Java enabled browser. With the release of Netscape Navigator 2.0 that includes Windows 95, Windows
NT, the MacOS, Sun Solaris, Sun OS 4.1.3, SGI IRIX, OSF/1, HP-UX with more to come. But wait. There's more!
Java isn't just for web sites. Java is a programming language that lets you do almost anything you can do with a
traditional programming langauge like Fortran or C++. However Java has learned from the mistakes of its
predecessors. It is considerably cleaner and easier to use than those languages.

As a language Java is

Simple

Java has the bare bones functionality needed to implement its rich feature set. It does not add lots of syntactic
sugar or unnecessary features.

Object-Oriented

Almost everything in Java is either a class, a method or an object. Only the most basic primitive operations and data
types (int, for, while, etc.) are at a sub-object level.

Platform Independent

Java programs are compiled to a byte code format that can be read and run by interpreters on many platforms
including Windows 95, Windows NT, and Solaris 2.3 and later.

Safe

Java code can be executed in an environment that prohibits it from introducing viruses, deleting or modifying files,
or otherwise performing data destroying and computer crashing operations.

High Performance

Java can be compiled on the fly with a Just-In-Time compiler (JIT) to code that rivals C++ in speed.

Multi-Threaded

Java is inherently multi-threaded. A single Java program can have many different things processing independently
and continuously.

Java is the programming language developed for the Web. One of the guiding principles of Java was that every
computer system would implement it in a standard way, which meant that, in theory, any software written in Java
can run unmodified on any computer system. It turned out there were practical limitations to this concept, but it
provided the impetus for the creation of a standardized set of infrastructure software components, called J2EE
(Java 2 Platform Enterprise Edition), which today forms the basis of many of the leading web systems software
platforms. Sun Microsystems owns and co-ordinates the development of Java, J2EE, and the client specifications
J2SE (Standard Edition) and J2ME (Micro Edition).

Features of Java

Here we list the basic features that make Java a powerful and popular programming language:

Platform Independence

The Write-Once-Run-Anywhere ideal has not been achieved (tuning for different platforms usually required), but
closer than with other languages.
PSS, MIG-250, Kanan Vihar, Phase-2, Patia, Bhubaneswar, Tel:2725404

Object Oriented

• Object oriented throughout - no coding outside of class definitions, including main().


• An extensive class library available in the core language packages.
• Throughout, e.g. no coding outside of class definitions, including main(). An extensive built-in class
library.

Simpler than C & C++

• no pointers
• no preprocessor
• automatic garbage collection

Familiarity

Similar enough to C and C++ that experienced programmers can get going quickly.

Simple

• Looks familiar to existing programmers: related to C and C++:


• Omits many rarely used, poorly understood, confusing features of C++, like operator overloading,
multiple
inheritance, automatic coercions, etc.
• Contains no goto statement, but break and continue
• Has no header files and eliminated C preprocessor
• Eliminates much redundancy (e.g. no structs, unions, or functions)
• has no pointers

Added features to simplify:

• Garbage collection, so the programmer won't have to worry about storage management, which
leads to
fewer bugs.
• A rich predefined class library

Object-Oriented

Java is an object-oriented language, which means that you focus on the data in your application and methods
that manipulate that data, rather than thinking strictly in terms of procedures.
In an object-oriented system, a class is a collection of data and methods that operate on that data. Taken
together, the data and methods describe the state and behavior of an object. Classes are arranged in a
hierarchy, so that a subclass can inherit behavior from its superclass.

Java comes with an extensive set of classes, arranged in packages, that you can use in your programs.

Distributed

• It has a spring-like transparent RPC system


• Now uses mostly tcp-ip based protocols like ftp & http

Java supports various levels of network connectivity through classes in the java.net package (e.g. the URL class
allows a Java application to open and access remote objects on the internet).

Interpreted
PSS, MIG-250, Kanan Vihar, Phase-2, Patia, Bhubaneswar, Tel:2725404
The Java compiler generates byte-codes, rather than native machine code. To actually run a Java program, you
use the Java interpreter to execute the compiled byte-codes. Java byte-codes provide an architecture-neutral
object file format. The code is designed to transport programs efficiently to multiple platforms.

• rapid turn-around development


• Software author is protected, since binary byte streams are downloaded and not the source code

Secure

Security is an important concern, since Java is meant to be used in networked environments. Without some
assurance of security, you certainly wouldn't want to download an applet from a random site on the net and let it
run on your computer. Java's memory allocation model is one of its main defenses against malicious code (e.g
can't cast integers to pointers, so can't forge access). Furthermore:

• access restrictions are enforced (public, private)


• byte codes are verified, which copes with the threat of a hostile compiler

Architecture-Neutral

compiler generates bytecodes, which have nothing to do with a particular computer architecture
easy to interpret on any machine

Portable

Java goes further than just being architecture-neutral:

• no "implementation dependent" notes in the spec (arithmetic and evaluation order)


• standard libraries hide system differences
• the Java environment itself is also portable: the portability boundary is POSIX compliant

High-Performance

Java is an interpreted language, so it will never be as fast as a compiled language as C or C++. In fact, it is about
20 times as slow as C. However, this speed is more than enough to run interactive, GUI and network-based
applications, where the application is often idle, waiting for the user to do something, or waiting for data from the
network.

Multithreaded

Java allows multiple concurrent threads of execution to be active at once. This means that you could be listening to
an audio clip while scrolling the page and in the background downloading an image. Java contains
sophisticated synchronization primitives (monitors and condition variables), that are integrated into the language
to make them easy to use and robust. The java.lang package provides a Thread class that supports methods to
start, run, and stop a thread, and check on its status.

Dynamic

Java was designed to adapt to an evolving environment:

• Even after binaries have been released, they can adapt to a changing environment
• Java loads in classes as they are needed, even from across the network
• It defers many decisions (like object layout) to runtime, which solves many of the version problems
that C++ has
• Dynamic linking is the only kind there is

Compiler/Interpreter Combo
PSS, MIG-250, Kanan Vihar, Phase-2, Patia, Bhubaneswar, Tel:2725404
• Code is compiled to bytecodes that are interpreted by a Java virtual machines (JVM) .
• This provides portability to any machine for which a virtual machine has been written.
• The two steps of compilation and interpretation allow for extensive code checking and improved
security.

Robust

Java has been designed for writing highly reliable or robust software:

• language restrictions (e.g. no pointer arithmetic and real arrays) to make it impossible for
applications to
smash memory (e.g overwriting memory and corrupting data)
• Java does automatic garbage collection, which prevents memory leaks
• extensive compile-time checking so bugs can be found early; this is repeated at runtime for flexibilty
and to check consistency
• Exception handling built-in, strong type checking (that is, all data must be declared an explicit type),
local variables must be initialized.

Several dangerous features of C & C++ eliminated:

• No memory pointers
• No preprocessor
• Array index limit checking

Automatic Memory Management

Automatic garbage collection - memory management handled by JVM.

Security

• No memory pointers
• Programs runs inside the virtual machine sandbox.
• Array index limit checking
• Code pathologies reduced by

I. bytecode verifier - checks classes after loading


II. class loader - confines objects to unique namespaces. Prevents loading a hacked "java.lang.
SecurityManager" class, for example.
III. security manager - determines what resources a class can access such as reading and
writing to the local disk.

Dynamic Binding

• The linking of data and methods to where they are located, is done at run-time.
• New classes can be loaded while a program is running. Linking is done on the fly.
• Even if libraries are recompiled, there is no need to recompile code that uses classes in those
libraries.

This differs from C++, which uses static binding. This can result in fragile classes for cases where linked code is
changed and memory pointers then point to the wrong addresses.

Good Performance

Interpretation of bytecodes slowed performance in early versions, but advanced virtual machines with adaptive
and just-in-time compilation and other techniques now typically provide performance up to 50% to 100% the
speed of C++ programs.
PSS, MIG-250, Kanan Vihar, Phase-2, Patia, Bhubaneswar, Tel:2725404

Threading

• Lightweight processes, called threads, can easily be spun off to perform multiprocessing.
• Can take advantage of multiprocessors where available
• Great for multimedia displays.

Built-in Networking

Java was designed with networking in mind and comes with many classes to develop sophisticated Internet
communications.

Features such as eliminating memory pointers and by checking array limits greatly help to remove program bugs.
The garbage collector relieves programmers of the big job of memory management. These and the other
features can lead to a big speedup in program development compared to C/C++ programming

Das könnte Ihnen auch gefallen