Back to GT CS-1331

Important Dates:

  • Released in 1995/1996 by Sun Microsystems

  • Oracle aquires Sun Microsystems in 2010

Overview:

  • Java was created by Sun Microsystems as a safer coding language alternative for C/C++

    • C/C++ can be prone to dangerous memory leaks
  • Java, like C++, is object oriented

  • Java applets

General Info:

  • Statements can be grouped together with a method

  • Program must have a method

  • Must have a method called “main”

  • Methods are enclosed in classes

  • File name must match class

Executing Programs:

  • Compiler vs Intepreter:

    • Java is a complied language

    • Compliers translate high-level code to low-level code and generates a new file

      • faster

      • needs to be complied for each machine

      • compiled once

    • Intepreter translates line by line and doesn’t create any new files

      • slower

      • runs on any machine

      • intepreted every time is run

  • Java Hybrid Approach:

    • Java code can either be compiled or intepreted

    • Java complies a bytecode and stores it into a .class file

      • This bytecode can then be intepreted, which is similar to compile speed as bytecode is fairly low level
    • Java code runs in the JVM (Java Virtual Machine)

      • Code is run by Intepreter and not by cpu/hardware

      • Allows code to be run on any device that has Java installed

  • Commands needed to run a project:

    1. Javac Filename.java (Compile) Not mandatory for basic programs
    2. Java Filename (Intepret)