Introduction to Java Programs
This module discusses the basics of Java programs. You will begin by finding out about the standard Java class library, also known as the Java API.
You will then examine the differences between applets and applications.
In addition the command-line arguments and standard I/O in Java will be discussed.
You will begin assembling the course project, an application which will display information about the planets in our solar system.
Module Learning Objectives
After completing the module, you will have the skills and knowledge necessary to:
Explain the importance of the Java API
Describe the difference between applets and applications
Process command-line arguments in Java applications
Use standard I/O to input and output data in Java applications
Design and build basic Java applications
Java Virtual Machine
Java is both a compiled and an interpreted language.
Java source code is turned into simple binary instructions, much like ordinary microprocessor machine code.
However, whereas C or C++ source is reduced to native instructions for a particular model of processor, Java source is compiled into a universal format instructions for a
virtual machine. Compiled Java bytecode is executed by a Java runtime interpreter. The runtime system performs all the normal activities of a hardware processor,
but it does so in a safe, virtual environment. It executes a stack-based instruction set and manages memory like an operating system.
It creates and manipulates primitive data types and loads and invokes newly referenced blocks of code.
Most importantly, it does all this in accordance with a strictly defined open specification that can be implemented by anyone who wants to produce a Java-compliant virtual machine.
Together, the virtual machine and language definition provide a complete specification.
There are no features of the base Java language left undefined or implementation-dependent.
Java specifies the sizes and mathematical properties of all its primitive data types rather than leaving it up to the platform implementation.
The Java interpreter is relatively lightweight and small; it can be implemented in whatever form is desirable for a particular platform.
The interpreter may be run as a separate application or it can be embedded in another piece of software, such as a web browser.
Put together, this means that Java code is implicitly portable.
The same Java application bytecode can run on any platform that provides a Java runtime environment.
You do not have to produce alternative versions of your application for different platforms, and you do not have to distribute source code to end users.