# Under-the-hood: Java

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1720000144733/1e6246a1-ea4a-4257-8bab-7a3fa5be5ded.png align="center")

Before we go onto each component of the above diagram we must know the basics. So, first thing first -

### tl;dr

Zoom out a bit from complex compiler designs termonologies and whatever scratches the part of your mind at night. We have tons of programming languages, they all are in some form of ***textual format*** that is readable by us humans. At the end of the day, all we want is to execute that piece of code inside a processor. Thus all we need to worry about is converting that sugar-coated code into machine code cause our cute little processor only understands that.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1719689126904/082d472e-46a3-480a-aa84-99fe99771b7c.png align="center")

The computation in the middle is the real work here. Whatever components a programming language includes all work towards one goal, the goal to spit machine code at the end. Let's bring in some colors. Interpreters, compilers, assemblers, loaders, linkers, and parsers are a few of them that can fit into computation land. Programming languages can utilize the compilation of computation tools like in here ***Java.*** It is both compiled and Interpreted. Now let's learn the components involved in executing your Java code, end-to-end.

## Components:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1719690932393/f6419e41-bca6-44b9-83da-6434f9bf0af6.png align="left")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1719690181895/052da19b-5354-4024-b8b5-164c0866bde5.png align="center")

Source code is what we refer to as pure language code. It is nothing far from just a text which always gets converted into another text format. It could be compiled, interpreted, or transpiled.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1719691130172/cb1daf11-6ce0-41ad-847d-c04e70e8f9a0.png align="left")

Java uses ***Javac*** to compile source code into Bytecode (.class) files.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1719691243552/27f5ec7d-189d-4acf-9c0c-d5650340c2bb.png align="left")

It is an intermediate representation code with a ***.class*** file extension.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1719692131485/0952ff1d-e03e-448d-8322-07b2959ba548.png align="left")

It reads Bytecode and converts it into machine code line by line cause it's an interpreter.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1719692176768/50d11ff6-c74a-4cd9-a9d7-d44b774393c4.png align="left")

Machine code is the most basic form of instruction that a computer's central processing unit (CPU) can execute directly.

---

## FAQs

<details data-node-type="hn-details-summary"><summary>Is Java an interpreted or compiled language?</summary><div data-type="detailsContent">It's both.</div></details><details data-node-type="hn-details-summary"><summary>Where can I learn more about JVM?</summary><div data-type="detailsContent">Here - <a target="_blank" rel="noopener noreferrer nofollow" href="https://www.ibm.com/think/topics/jvm-vs-jre-vs-jdk#:~:text=Java%20virtual%20machine%2C%20or%20JVM,because%20it%20runs%20Java%20programming" style="pointer-events: none">https://www.ibm.com/think/topics/jvm-vs-jre-vs-jdk#:~:text=Java%20virtual%20machine%2C%20or%20JVM,because%20it%20runs%20Java%20programming</a>.</div></details><details data-node-type="hn-details-summary"><summary>Are machine code and object files different?</summary><div data-type="detailsContent">Yes.</div></details><details data-node-type="hn-details-summary"><summary>Where can I reach out if my question is unanswered in this blog?</summary><div data-type="detailsContent">This blog is not the final version thus it keeps evolving. I seek feedback and update my blog on demand to keep it updated. Just comment down below and I'll be checking them periodically.</div></details>
