===== What is Java ===== Java is a programme language created by Sun Microsystems in 1995 as a core component of Sun's Java platform. Java source code is written in a plain text, but unlike many other programming languages including C and C++ when Java is compiled, it is not compiled for any specific machine and operating system, rather into platform independent byte code. This byte code is then interpreted by the Java virtual Machine (JVM). This means that the whilst the byte code is platform independent, the JVM is platform specific. This complete view leads to one of the core parts of the Java philosophy, namely : **"Write a program once, compile it once, and run it anywhere."** ===== The Java Virtual Machine ===== The JVM is at the heart of Java by providing the environment for the byte code to run. A Java virtual machine can either interpret the bytecode one instruction at a time or the bytecode can be compiled further for the real microprocessor using what is called a just-in-time compiler. JIT compiling, not interpreting, is used in most JVMs today to achieve greater speed. The JVM provides a platform for the byte code to perform the following operations: * Load and store * Arithmetic * Type conversion * Object creation and manipulation * Operand stack management (push / pop) * Control transfer (branching) * Method invocation and return * Throwing exceptions * Monitor-based concurrency ===== Garbage Collection ===== Garbage collection is an important feature of Java. Its purpose is twofold: - Free the memory used in the JVM by any objects that is no longer referenced by the JVM - Combats memory heap fragmentation to create larger contiguous memory spaces for new objects - Prevents JVM crash situations by preventing out-of-bounds memeory allocations There is unfortunately a penalty to the Garbage Collector, namely that it adds an overhead that can affect program performance. The JVM has to keep track of which objects are being referenced by the executing program, and finalize and free unreferenced objects on the fly. This activity will likely require more CPU time than would have been required if the program explicitly freed unnecessary memory. In addition, programmers in a garbage-collected environment have less control over the scheduling of CPU time devoted to freeing objects that are no longer needed. Fortunately there has been much work in the field of garbage collectors , to the point now where they run in a separate thread to the JVM. ===== Useful Links ===== [[http://en.wikipedia.org/wiki/Java_language|Java on Wikipedia]] [[http://en.wikipedia.org/wiki/Java_virtual_machine|Java Virtual Machine on Wikipedia]] [[http://www.javaworld.com/javaworld/jw-08-1996/jw-08-gc.html?page=1| Java World Article on Garbage Collectors]]