Aqua Phoenix
     >>  Lectures >>  Java 1  
 

Navigator
   
 
       
   

1.2 Java Anatomy

For any given programming language, the developer needs to understand the development and execution environment. For Java, here are the important components of the environment:
  • Java files: have extension of sort .java and constitute the source code
  • Class files: contain Java Byte code generated from source files. They carry the extension .class
  • Libraries (JAR): contain collections of classes. They carry the extension .jar for Java ARchive. JAR files can contain any other files that are part of a library, including source files, text files, images, movies, data files, etc.
  • Java Compiler: javac. The Java Compiler generates byte code from source code. In the process, the compiler creates one or more .class files for a given .java source file.
  • Java Virtual Machine (JVM): executes Java byte code from .class files
  • Java Runtime Environment (JRE): java creates a JVM and executes the byte code in that Virtual Machine.
  • AppletViewer: appletviewer also creates a Java Virutal Machine, but one specifically for applets.
  • DLL or SO: additional native libraries (Windows: .DLL, Unix: .SO) may be necessary for some advanced packages, e.g. Java Media for playing back video and audio.

1.2.1 Java Virutal Machine

The Java Virtual Machine is a critical piece of the execution environment, that you should understand a little bit. The JVM is the reason Java code is portable. Essentially, JVMs have been compiled by Sun for some of the major OS platforms: Windows, Apple, Solaris, Linux, Irix, etc. JVMs are the layer between compiled Java byte code and the underlying operating system. Because Java byte code for a given program is the same, regardless of what platform it was compiled on, it is portable and can be executed by a JVM on any other platform.

As a comparison, a compiled C or C++ program do not require a virtual machine. The compiled code is already ready for the specific platform, but cannot be ported, since it was created for a very specific instruction set.

The reason why Java tends to be slower than other software lies mostly with the additional burden of the Virtual Machine. However, some improvements have been introduced by which Java byte code is compiled further (Just In Time (JIT) compiler) for specific platforms.