Java Basics

Posted on Posted in Uncategorized

Here we discuss basic concepts surrounding Java, they are terms and principles that surround java as a language.

JDK vs JRE

JRE – Java Runtime Environment – environment to enable java applications to run.

JDK – Java Development Toolkit – everything need to develop a java application, which in turns includes a runtime environment (JRE)

JVM – Java Virtual Machine, is an abstract concept of the machine, it is required to run java applications. JRE is the actual implementation of the JVM with libraries etc.

Stack vs Heap

Heap – objects created globally for the application resides in the heap. References are pointed inside the heap. Strings are created here in the heap.

Stack – are for short lived memory allocation, for example, variables created in a loop, or in a method that are no longer accessible once the method/loop ends.

(not my image)

Just In Time Compiler

Java uses JIT Compiler or Just In Time Compiler, which runs after the program has started. Traditionally for an EXE file, it gathers all the necessary things before executing the application. In Contrast, Java has dynamic access to runtime information.

https://en.wikipedia.org/wiki/Just-in-time_compilation:

 The JIT compiler reads the bytecodes in many sections (or in full, rarely) and compiles them dynamically into machine language so the program can run faster. This can be done per-file, per-function or even on any arbitrary code fragment; the code can be compiled when it is about to be executed (hence the name “just-in-time”), and then cached and reused later without needing to be recompiled.

 

Leave a Reply