touque.ca > Education Commons > Java > Resources > Basics

Java

Introduction

Java programs are stored in plain-text files and then compiled into bytecode, which is one step removed from executable code. Each platform (each hardware and operating system combination) has a Java Virtual Machine, specific to that platform, whose job is to interpret and execute the bytecode. By writing Java code for a virtual machine, rather than a specific machine, it is hoped that programmers can “write once, run everywhere.”

Programs can be written in any plain-text editor like Notepad++ (Windows) or TextWrangler (OS X). Oracle Corporation (formerly Sun Microsystems) provides free of charge a Java Development Kit (normally called the “JDK”) which comprises a compiler (javac), an application launcher (java), and an API documentation generator (javadoc). (Also available is an applet viewer, which will not be discussed here.) The compiler is used to convert plain-text files (with the extension .java) to bytecode files (with the extension .class). The bytecode files can then be interpreted and executed by the application launcher. The compiler and application launcher are command-line tools and provide the minimum functionality necessary for code development.

In our courses, we will use instead the BlueJ integrated development environment (IDE). The IDE comprises a text editor, compiler, debugger, and a runtime environment. The integration of these tools makes easier the iterative program-development cycle of code, compile, run, and debug.

Java Technology

  1. Source code. Java programs are plain-text files written in any text editor and stored with the .java extension.
  2. Compilation. Using a program called a compiler, the source code is converted into bytecode with the .class extension.
  3. Java Virtual Machine. A program called a Java Virtual Machine (JVM) interprets bytecode into the machine language of a particular computer processor. As each bytecode statement is interpreted, it is executed by the processor.
  4. Platform independence. Because JVMs are available for different computer platforms, the source code of a program can be written and compiled on one platform, such as Windows running on an Intel processor, and the resulting bytecode can be run on another platform, such as OS X running on a PowerPC processor or Android running on a Nvidia processor.

transition of source code through compilation and interpretation to executable code

An overview of the software development process. Retrieved 2012-12-30 from <http://docs.oracle.com/javase/tutorial/getStarted/intro/definition.html>.

Java Development Kit

  1. Java Runtime Environment (JRE): Java Virtual Machine, Application Programming Interface (standard class libraries), and other components required to run Java programs.
  2. Java Development Kit (JDK): superset of the JRE including compilers (most notably: javac), debuggers, and the javadoc documentation generator.
  3. Available from Oracle Corporation.

Development Cycle

  1. As part of our program development cycle, source code is written in a text editor, compiled, and then executed.
  2. The process of writing, compiling, and executing a program can be accomplished with individual programs:
  3. The process of writing, compiling, and executing a program can be accomplished within a single program called an Integrated Development Environment.
  4. Examples of popular IDEs include BlueJ, DrJava, and Eclipse.
  5. Program development is an iterative progress of coding, compiling, executing, and debugging.

screenshot of DOS invocation of editor, Java compiler, and Java launcher

Command line invocation of DOS editor (editing session not shown), Java compiler, Java launcher, and documentation generator.

touque.ca > Education Commons > Java > Resources > Basics

[This page last updated 2020-12-23 at 12h12 Toronto local time.]