Lesson: Java Language Architecture

Overview: 
Explore the architecture of Java.
Objectives: 

Understand the basic architecture and implementation of the Java language.

Content: 

Java is a text based programming language. This means source code is written and stored in a text file and then passed through a compiler which produces the executable program (also called the object code). With C or C++ and other languages, the language and resultant executable program is tailored to a specific operating system or hardware platform. For example, a Windows program written in C will only execute on a Windows device and may or may not run on all variations of Windows or Windows devices. This dependency or customization of languages to specific hardware or operating systems can be a problem in some cases.

Java seeks to solve this problem by allowing Java source code to be written and compiled for one virtual hardware/operating system platform. The Java compiler outputs a generic object code called bytecode, which is not specific to any platform. This bytecode is then executed by a Java Virtual Machine (JVM), which is an interface between bytecode and each different platform. This JVM is specific to each platform and translates the generic bytecode of a Java program to the native object code of the target platform for execution. This allows a program compiled from a single Java source file to be run on systems other than the system on which it was compiled.

The processors (controller) on your robots use the Linux operating system and have a JVM already installed on them (this is done when installing your robotics SDK). Your Java robot programs are run by that JVM on Linux even though they were written on Windows.

The final piece of Java is the Java Class Library. This is pre-built library of utility functions that facilitate building programs and also provide generic access to the features of the target platform. This library or API is provided as part of the Java SDK. We will discuss the JCL in more detail later.

In addition, each robot platform SDK will provide a Class Library that provides access (API) to the specific components and capabilities of the robot hardware.

When it comes to installing Java on your PC and your robot there some terms to understand. The Java Runtime Environment or JRE, is installed when all you want to do is run Java programs developed by someone else. If you want to develop Java programs, you need the Java Deveopment Kit or JDK. The JDK contains the JRE so you typically don't need both but its ok and not uncommon for both the JDK and JRE to get installed on a PC. You can have multiple JREs or JDKs of different versions installed and use them for different purposes. For robotics you install the JDK on your development machine and the JRE will be installed on your robot controller. Actual installation of these Java packages will be covered in a later lesson.

 

Lesson navigation: