Java Tutorial

Intertech Tutorials

Tutorial Objectives:


Java is currently the most popular programming language. Why? What made it so popular, and why is it used today in a variety of applications? From tiny applications that run on cell phones and embedded devices to huge distributed enterprise applications, Java has had an enormous impact on the software industry. Its presence has forced organizations like Microsoft to adopt a different approach to programming.

In a word, Java’s strength lies in its portability. The mantra by which all Java developers live by is “WORA,” or write once, run anywhere. What makes WORA work in Java?

This chapter introduces you to Java goals and philosophy. After reading this chapter, you will have a much better understanding of the Java platform and why it is so powerful.

You will be introduced to a simple Java application, the ubiquitous ‘Hello World’ application but written in Java. You will also gain an appreciation for how Java applications are built, compiled, and executed.

The Java Platform:

The Java platform has two components: The Java API is a large collection of ready-made software components that provide many useful capabilities. The API provides input/output, graphical user interface, database access, and more. The Java API is grouped into libraries of related components called packages. Your Java applications call these library components, thereby greatly reducing your development time. The API available to you depends on which version and edition of Java you are using. The Java Virtual Machine (JVM) insulates your application from platform specifics.

In Java, applications are both compiled and interpreted. The Java compiler compiles your application source code to an intermediate language that is interpreted by the JVM. The intermediate language is called bytecode.
The bytecode is not machine code that gets executed directly. Instead, the JVM translates (i.e., interprets) the bytecodes into machine code, which gets run by the actual platform. In other words, bytecode is like the “machine code” for the JVM. The bytecode is platform independent and can therefore be interpreted by any JVM. JVMs are built specific to particular platforms (hardware and OS).

More information about the JVM is provided later in this chapter. In order to “run” your Java application, what is needed is both the Java API library used by your application and the JVM. The JVM and Java API required to run Java programs is called the Java Runtime Environment (JRE). The JRE does not include tools to create or develop Java applications. It is strictly the minimum software that must be installed on a machine in order to run Java applications.

Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.