Behind the Scene of Java

JVM, JRE and JDK/ Memory Allocation Java

I personally feel very comfortable coding in Javascript and Ruby now, since I have been writing in these languages for the past several months. Javascript and Ruby I wouldn’t say are easier language but they are very beginner friendly.

What I mean by this is allot of the behind the scene action isn’t strictly necessary to know if you are just code or following a tutorial. Now that I have started coding in Java I’m starting to realize I’m learning more about how code gets processed(Java Specific).

So today I’ll be pulling back the veil and going through JVE, JRE, and JDK. As well as a brief oversight of Memory Allocation in Java.

JVM ,JRE and JDK

Below is a picture explaining how when you write your logic(Code) in a Java file its converted into class file so that the machine can read your logic and run it.

Overview:

  • JVM is the java virtual machine that runs the java byte code.
  • JVM can be loaded on various hardware platforms, byte codes are the machine language of JVM. So Java is a better portable language. JVM is the entity that makes Java portable; there are different implementations of JVM for different OS (mac, windows, linux) etc.
  • JRE is java runtime environment that is sufficient to run the program.
  • JRE = JVM + library files/java package classes (Util, Lang, Math etc).
  • JDK is java development kit, required to write, compile and run a program.
  • JDK = JRE + Tools needed to develop java program.

Memory Allocation

Brief pointers:

  • Each time object is created in Java it is stored in heap memory.
  • Primitive variables and local are stored in stack, member variables in heap.
  • In multithreading each thread will have its own stack but will share same heap. We will discuss multithreading later in part 2.
  • Methods and variables are pushed to the stack when a method is invoked and stack pointer is decremented when call is completed.
  • 32 bit OS can’t use more than 4GB RAM for java application. 64 bit use more memory for same object, almost twice.
  • Primitive int uses 4 times less memory than Integer.

The below table gives an idea of various datatypes and range of values it can hold.

Please share you you’ve learned something and keep coding!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to show bootstrap alerts based on your modelstate in MVC 5

Develop Docker Remotely from your Mac like a Pro

Animations challenges #2 — Asana Loader animation

Creating A Server Authoritative Game System Using Unity’s NEW Transport Layer | Part 3

Windows application Test Automation (Part 3)

Installing Unity 3D

Add host entries in docker for mac

Opendistro Kibana OpenID Okta

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Erick Villeda

Erick Villeda

More from Medium

Protect Jar/War project with Java VME mode

Collection Framework in Java

Java Naming Conventions