Please disable adblock to view this page.

← Go home

Java Fundamentals

java-display

April 29, 2017
Published By : Pratik Kataria
Categorised in:

Principles of Java

  • Simple
  • Objected-Oriented
  • Robust
    • Methods, functions and properties
    • Code in small chunks – easy to debug
  • Portable
  • High Performance
    • JVM has improved
  • Dynamic, interpreted and threaded
    • Run-time interpretation
    • Apps can do more than one thing at a time
    • Compatibility between different data types

Software Stack

  1. Operating System — Windows / Linux / Mac
  2. Java Virtual Machine (JVM) — Android / IBM / Sun microsystems
  3. Core runtime and additional libraries — JDK / JRE
  4. Compiled ByteCode

Java  v/s  C++

Java C++
Not compatible with prev. languages Compatible with C
Compiled to bytecode Compiled to native machine language
Calls to native functions go through JNI Allow direct calls to native system libraries
Write once, run anywhere Write once, compile anywhere
Runs in a protected virtual machine (JVM) Low-level system functions
Managed memory access Explicit memory management and pointers
Limited single inheritance Multiple inheritance

Note:

  • JNI (Java Native Interface) is sometimes referred to as Genie
  • In Java memory is managed by itself

Java  v/s  JavaScript

Java JavaScript
Not compatible with prev. languages Based on ECMAScript standard
Compiled to bytecode Not compiled — interpreted at runtime
Calls to native functions go through JNI No native function calls in browser
Write once, run anywhere Compatibility with every browser
Runs in a protected virtual machine (JVM) Restricted to browser window
Managed memory access Managed memory access
Inheritance through class Inheritance through prototype


Java Editions

  • Standard Edition (SE)
  • Enterprise Edition (EE)
  • Micro Edition (ME)
    • for sensors, mobile devices and micro-controllers. E.g. Sim-Cards

Note:

  • JRE includes JVM and is not required by default
  • JRE must be updated regularly as security issues are common
  • Mobile systems have their own Java Runtime
  • JDK includes compilation and packaging (important for command line execution)
    • java: runtime
    • javac: compiler
    • javadoc: docs builder
    • jar: archive builder