Lars Vogel, Simon Scholz (c) 2008, 2019 vogella GmbH
TABLE OF CONTENTS
- Introduction to Java
- Installation of Java
- Exercise: Write, compile and run a Java program
- Base Java language structure
- Java interfaces
- Annotations in Java
- Variables and methods
- Import statements
- More Java language constructs
- Cheat Sheets
- Integrated Development Environment
- Exercises - Creating Java objects and methods
- Solution - Creating Java objects and methods
- Type Conversion
- Java statements
- Loops in Java
- System properties
- Links and Literature
vogella training and consulting support
Appendix A: Copyright, License and Source code
Introduction to Java programming. This tutorial explains the installation and usage of the Java programming language. It also contains examples for standard programming tasks.
Introduction to Java
1.1. A small history of Java
Java is a programming language created by James Gosling from Sun Microsystems (Sun) in 1991. The target of Java is to write a program once and then run this program on multiple operating systems. The first publicly available version of Java (Java 1.0) was released in 1995. Sun Microsystems was acquired by the Oracle Corporation in 2010. Oracle has now the steermanship for Java. In 2006 Sun started to make Java available under the GNU General Public License (GPL). Oracle continues this project called OpenJDK.
Over time new enhanced versions of Java have been released. The current version of Java is Java 1.8 which is also known as Java 8.
Java is defined by a specification and consists of a programming language, a compiler, core libraries and a runtime (Java virtual machine) The Java runtime allows software developers to write program code in other languages than the Java programming language which still runs on the Java virtual machine. The Java platform is usually associated with the Java virtual machine and the Java core libraries.
The Java language was designed with the following properties:
Platform independent: Java programs use the Java virtual machine as abstraction and do not access the operating system directly. This makes Java programs highly portable. A Java program (which is standard-compliant and follows certain rules) can run unmodified on all supported platforms, e.g., Windows or Linux.
Object-orientated programming language: Except the primitive data types, all elements in Java are objects.
Strongly-typed programming language: Java is strongly-typed, e.g., the types of the used variables must be pre-defined and conversion to other objects is relatively strict, e.g., must be done in most cases by the programmer.
Interpreted and compiled language: Java source code is transferred into the bytecode format which does not depend on the target platform. These bytecode instructions will be interpreted by the Java Virtual machine (JVM). The JVM contains a so called Hotspot-Compiler which translates performance critical bytecode instructions into native code instructions.
Automatic memory management: Java manages the memory allocation and de-allocation for creating new objects. The program does not have direct access to the memory. The so-called garbage collector automatically deletes objects to which no active pointer exists.
The Java syntax is similar to C++. Java is case-sensitive, e.g., variables called myValue and myvalue are treated as different variables