Home : Course Map : Chapter 1 : Java :
Code Compatibility
JavaTech
Course Map
Chapter 1
Introduction
History
What is Java?
Versions
Java 5.0
Features

Java Process
Tools
Documentation
Compatibility
Getting Started
Simple Applet
Simple Application
Starters
Exercises

    Supplements
Interpret/Compile

Making WebPages
Plug-in
Java 5.0 Features
The JVM
Advanced JVMs
Alt. Compilers
Alt. JVMs
Java Deployment

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

We want to emphasize that Sun has maintained good compatibility among codes written with the different versions. Generally, the newer versions maintain compatibilty with older code. The approach has been to add new features without subtracting any older features. (In some cases, such as the event handling system introduced in Java 1.1, code using newer classes and techniques should not be mixed in the same program with older version code.)

Thus far, Java maintains backwards compatibility. A program written according to Java 1.0 will compile with a Java 5 compiler. (Though some obsolete methods will generate "deprecation" warning messages from the compiler.) The bytecode from a Java 1.0 compiler will still run in a Java 5 virtual machine.

Note: Running code in older JVMs is a different matter. As of version 1.4, even when the source code is compliant with version 1.1, you must explicitly target the compiler output to 1.1 bytecode if you want it to run with a version 1.1 JVM. That is,

  > javac -target 1.1 MyApplet.java

will allow this applet program to run with a 1.1 JVM.

You can in some cases run into problems if you mix code between versions in the same program . For example, the handling of events, such as mouse clicks, changed significantly from 1.0 to 1.1. A program can use either of the event handling approaches but it cannot contain both.

We will mention compatibility issues as we encounter them.

Applets

We compiled our codes with Sun's version J2SE 5.0 compiler and tested the programs with the 5.0 JVM . For the applet examples, we assume the reader has installed the latest version of the Java plug-in. When you install the SDK, it will also install the Java plug-in in the browsers it finds on your system.

Currently (circa 2004) many people are still using browsers that only run applets compatible with Java 1.1 (i.e. the standard JVM version installed in the IE browser is still for Java 1.1). If your goal is to write applets for the broadest possible audience, then you will need to write code limited to version 1.1 classes and methods. In general, though, we recommend using the full capabilities of Java 5.0 when writing applets for desktop PC users..

You can set up applet tags in the web page to initiate the downloading of a plug-in if it is not present. The simplest approach, though, is just to tell visitors to your web pages with applets that if an applet fails to run, they should install the plug-in by going to www.java.com and clicking on the "Get It Now" button.

References & Web Resources

Latest update: Oct.9.2004

            Tech
Java in Science
    & Engineering
Benefits
Shortcomings
RealWorld Examples

           Physics
Java in Physics
SimulationTypes
Simulate&Analyze
Sim. in Experiments
  Demo 1: Event
  Demo 2: Continuous
  Demo 3: Static

Learn by Coding
Exercises

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.