- Podcasts
- The Java Developers Hub
- Write Your First Java Program | JVM, JDK, JRE & Java Editions Explained
Write Your First Java Program | JVM, JDK, JRE & Java Editions Explained
The Java Developers Hub
- December 3, 2026
- 42 min
- Episode 9
About this episodeReady to write your first Java program? In this episode, you'll take your first practical step into Java programming while learning the…
- How to write your first Java program.
- Understanding the basic structure of a Java application.
- How to compile and execute Java source code.
- Understanding the Java Virtual Machine (JVM).
- What the Java Development Kit (JDK) does.
- Understanding the Java Runtime Environment (JRE).
- Differences between JVM, JDK, and JRE.
- How Java bytecode works.
- Understanding Java's platform independence.
- Introduction to Java Standard Edition (Java SE).
- Understanding Java Enterprise Edition (Java EE).
- Introduction to Java Micro Edition (Java ME).
- How these Java technologies fit into software development.
- Complete beginners learning Java programming.
- Computer science and software engineering students.
- Aspiring Java developers.
- Developers transitioning from other programming languages.
- Anyone interested in understanding Java architecture and execution.
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Write Your First Java Program | JVM, JDK, JRE & Java Editions Explained
Yes, so let's start. Welcome back Coder Army to our Java series. And today we are going to understand three more important topics of Java. What is JVM? What is JRE? And what is JDK? Apart from this, we will know what is Java Standard Edition? What is Enterprise Edition? What is Micro Edition? There are a lot of terms, right? And sometimes these terms are very confusing for a lot of people. Especially when you are asked a question in an interview or when you should use it etc. So let's see, you will enjoy it a lot. Again, because we are understanding Java in-depth, we read every concept very deeply. We apply the first-thought principle. So we may go a little slow, but we will cover Java so well that you will enjoy it. So let's go to the screen quickly and understand this topic. So look, first of all, we saw JVM a little in the last lecture, what is a Java virtual machine. Okay. In this lecture, we will go into a little more depth and understand what is JVM. Apart from that, JRE and JDK are two new terms which we will understand well. It is very interesting. So let's see what to do. First of all, I told you that let's suppose we have a source code of Java. Source code means a file in which we have written some code of Java. Let's say I call that file hello.java. As we know, if we make a java file, then its extension is always. java and its name can be anything. For now, I have kept its name as hello. So, hello.java has become a file in which some java code has been written. So, as we have not gone into syntax yet, let's say some java code is written in it. We don't know what code is written. And we had discussed that When we give the code of Java to a compiler You know what is a compiler? Compiler has only one function To convert this source code Now again in terms of Java Where do we convert this source code? We had read that we convert the source code to our byte code So let's say we have our byte code Now who did this work? Compiler did it. Now where is this compiler present? We will discuss it in some time. But now interestingly our JVM works here. Now we had discussed that this bytecode is platform independent. What does it mean? It means that multiple platforms, let's say platform 1, platform 2, we can run this bytecode. Now to run this bytecode, one thing is important in every platform and that is the JVM of that platform. Similarly, JVM should also be here, right? So what does it mean to say? That we have a source code, compiler will convert it to bytecode and we will be able to run that bytecode on any platform using JVM of that platform. So if we want to run it on platform 1, then we will have to run it on JVM. If we want to run it on platform 2, then we will have to run it on JVM. And what will be the job of JVM? To convert this bytecode. In which? In our machine code. Machine code. Okay? Let me write it down here. Machine code. Now this machine code you know that it is platform specific. So, if its machine code, let's say 0, 1, 0, 0, something like that, then its machine code is not necessary to be like that. Its machine code can be different. Let's say, its will be 1, 1, 0, 0, something, something. But, every platform has its own machine code. And, whose job is to generate that machine code? JVM's. Okay. We understood this. Okay. Now, let's understand a little bit of our Java hierarchy. That every term in Java How did it come? So to understand this, there is a very simple way. First comes our JVM. After that comes our JRE, Java Runtime Environment. Now let's discuss about this. And last comes our JDK. So why did I make such concentric circles? Now you will understand. First of all, let's take a look at their full form. So this is their full form. First of all, we have JVM, which we call Java Virtual Machine. Above that, we have JRE, which we call Java Runtime Environment. And lastly, we have JDK, which we call Java Development Kit. Now, what are all these Java Development Kit, Runtime Environment, Virtual Machine, etc., etc.? So, we will understand it one by one. So, first of all, as I said, JVM exists in our inner circle. Okay. So, once again, let's understand what was the work of JVM. It was simple. You know, to translate bytecode into machine code. Okay. To translate bytecode into machine code. Very good. But how will it be done? Right? This is the question. So, we will have to understand this. Okay. So for that, let's take another example. So let's suppose we have a source code of our java again. In this source code, some code of java will be written. Again, we can call it hello.java. Now we will pass this source code through the compiler. Where is the compiler now? Again, we will read it later. And we will get our bytecode And from here the work of JVM starts Once we get the bytecode Now here let's say we want to run it For a particular platform P1 So we make a P1 platform P1 We want to run it like this You must remember what a platform means Operating system plus a processor Combination So let's say for example here we take Windows plus, let's say, Intel's x86 processor. Okay? So, for this, for this platform, I have to run this bytecode. Okay? That means, what will happen? On this platform, a JVM will be present. JVM will be present. Okay? Now, how will JVM run this bytecode? Right? Now, as we discussed, what is JVM? JVM is a virtual machine. One second. Yes. JVM is a virtual machine. Virtual machine means you can understand it as a virtual computer. Basically, it is an environment in which our bytecode runs. So, in this environment, our bytecode runs. Very good. Now, how does it run? Any thing which is a bytecode, we had said that bytecode is an intermediate code. This is not a machine code. How does JVM convert this into machine code, that is, into zeros and ones? Now, any code, whether it is byte code or source code, if we want to convert it into machine code, then we will need a compiler, a software, right? Which will read the code and convert it into machine code, convert it into zeros and ones. Because what we discussed was that any of our machine, right? Let's say any of our platform, this platform, right? What will this actually be? It will be a machine. Any of our machine, only understands 0s and 1s, right? So if this platform is P1, which only understands 0s and 1s, then we will have to give it 0s and 1s only. And this JVM will easily take a bytecode and convert it into machine code for this machine. So what did I say? We need a software that can convert bytecode into machine code. Now, at this time, we have two types of software. Okay? First is Compiler. And the second one is Interpreter. And this is also a very interesting question for Java. Is Java a compiled language or an interpreted language? We will answer this. First, let's understand the difference between the two. What is a compiler and what is an interpreter? First of all, both have the same function. Both have the same function. And what is their function? To take any source code and convert it into machine code. Okay? Simple. Now for this step also, a compiler was required which converts source code to bytecode. It's not necessary that compiler or interpreter always generates machine code. Compiler means, you can understand it simply like this. Take one program and convert it to another language. Here you are taking a Java program and converting it to bytecode. In the other case, you will take bytecode and convert it into machine code. So, this is the definition of compiler. The same interpreter does the same. Interpreter can take a source code and convert it into machine code. So, what is the difference between the two? And which one do we use for Java? So, first of all, if we talk about compiler. So, what does compiler do? Your... It reads it all at once and generates it in the machine code. So here was the source code, here let's say it generated some machine code. Now this machine code that it generated, it reads the entire file at once and generates the entire machine code. And now it runs this machine code on some system. Because a computer will only understand a machine code. Now where will this machine code go? It will go to a system. What will happen in that system? There will be CPU in that system. CPU will run it. And what will we get? We will get an output. Simple. So what did we follow? We took a source code, converted it into machine code using compiler. And where does machine code run? On system. In system, there is CPU and what will it give us? It will give us an output. Simple. So what does our interpreter do? See, our interpreter also does almost the same thing but in a slightly different way. What does he do? He takes source code. And it doesn't generate it in machine code at once, but it generates source code line by line in machine code. What does it mean? First, it generates one line, then it gives it to its system, the system gives it to the CPU, basically the processor What did it do? Then it generated a line again. Let's say the next line is 110. Okay. Then it will give this line to the machine again. It will run the CPU and the output will come. Then the next time a line will come again. Okay. Let's say this time it comes 001. Then again the same process will follow. It will run on the platform. It will give an output of CPU etc. So if we write it carefully. Then our interpreter. What can we write? Convert output. code line by line ok and what we can write about our compiler convert code all at once bus There is such a small difference between the two. There is an interpreter and a compiler. You use both to convert the source code into machine code. One converts line by line and the other one converts everything together. Both have their advantages and disadvantages. So, no one is better than the other. Some languages are compiled languages and some are interpreted languages. What does compiled language mean? Internally, it uses a compiler. For example, our C, C + + is a compiled language. Compiled language. What does it mean? It means that if you take a code of C, C + +, then a compiler generates it directly in machine code. Similarly, our Python Python is our interpreted language which means there is an interpreter in between which converts it to machine code. Now in the case of Python, there are different things in between but we are not going into that now, we are going into the depth of Java. Now your Java is neither a pure compiled language nor a pure interpreted language but Java is both. which means it is compiled as well as interpreted. How? You know it. If we go back up, we saw that in any source code in Java, first we use the compiler and convert it to bytecode. And then to convert that bytecode to machine code, we need an interpreter. What did we understand? That if we have There is a JVM. What will JVM do? It will take the bytecode and through the interpreter, it will convert it line by line in the machine code. Now it is converting line by line, and you know that it also runs. So the interpreter converts one line, the CPU runs it and gives the output. Then the interpreter converts the second line, then the output comes, then the third line, output comes and so on. So this is the work of JVM. Simple. JVM takes a bytecode and converts it into machine code using interpreter. Now this used to happen earlier. In the 1990s when Java was getting popular, we used to use interpreter in this. Why did we use it? Now if we question this again from the first thought principle, why didn't we put a compiler in the starting? Why didn't we put a compiler here? So the reason for this was that we wanted the java program to start running as soon as possible. And the interpreter's job is to interpret one line, convert one line and run it quickly. Do the second line and run it quickly. Because look, java already follows a slow process. So if you understand carefully, java's code first goes to the bytecode from the compiler. And then what does JVM do with the bytecode? It converts to machine code. So already we are doing this one step of conversion. Then we have to do another step. Why? Because we have to make Java platform independent. Right? We have to make Java portable. Do you remember Vora? Write once, run anywhere. So we have to do these two processes to want this feature. Now it takes a lot of time to do these two processes. If we are using a compiler to convert a bytecode, then it would have taken a little time. Then if we use a compiler in JVM, it would have taken more time. So at that time, there were a lot of problems that we used an interpreter here, not a compiler. And what were the problems? Look, first of all, at that time, hardware used to be slow. Okay. Slow hardware used to exist. So if the hardware is slow, then first you are converting a language using a compiler to bytecode. Then again using a compiler, you are converting it to machine code. So it will take a lot of time. Same, your RAM was less, RAM was limited, disk was slow, you used to use disk, that was also slow. So we had a lot of limitations. So we wanted to run our language as soon as possible. For that, we put an interpreter in JVM. So that it converts line by line. One line was converted, we ran it. The other one was converted, we ran it. We'll see how this runs, the control flow of any program in the next lecture. But now you might have understood why we used an interpreter in the beginning. Now, as the times change slowly, our problems got eradicated. What happened? Now our hardware was not slow, our RAM was not limited, and our disk was not slow either. So what did we do in the modern era? We added a compiler to the interpreter with Java, which we called JIT compiler. JIT compiler, whose full form is just in time. just-in-time compiler. This is a very optimized compiler, okay? And it doesn't replace any interpreter. Basically, the existing interpreter in JVM didn't replace it, but it joined with it. That means, what happened now? Now, our JVM had an interpreter as well. Plus, he also had JIT compiler. By combining these two, he now converted a bytecode into a machine code. Now you'll say, why only two things? We could have kept only the compiler in use. Right? Even now, we know that hardware is fast, everything is there, disk is also very... It has become fast, RAM space is not limited, we are able to make a lot of RAM, there is a lot of everything. But the problem is that the compiler is still a bit slow. So we use the hybrid model of both, right? So what does JVM do? If you understand it in a little depth, what does JVM do? Look, JVM uses a very smart technique. It takes the bytecode, right? Because JVM is very smart, it reads the bytecode and sees which part of code is frequently used. So, the frequently used code is directly compiled using JIT, just-in-time compiler. So, what does it do? The frequently used code For that, it uses GIT compiler and converts it to machine code So that our frequent code which is being used in our program again and again It should not be converted line by line but it should be quickly converted to machine code And from the back, interpreter The less important code that is not being used frequently again and again, it keeps converting it line by line into machine code and at the same time keeps running it in our system. So I hope you have understood how we can basically we can use our just-in-time compiler and interpreter at the same time. Because what does our just-in-time compiler do? It quickly converts the code that is frequently used into machine code. At the same time, the interpreter keeps converting line by line into machine code. And what happens to the interpreter? It converts it into machine code and runs it through the processor. And the processor runs the code at the same time and our output keeps generating. Now if you watch videos on youtube about c + + and java speed test then you will see that c c + + is still faster than java In running process, obviously because what do you do in C + +? You take the code directly and run it. Now, one step increases in Java. So basically, Java's compilation is slow. Means the process before converting to machine code is a bit slow. But once Java's program is run, then Java's program provides us with many more features. Like we discussed that it is portable, simple, secure, etc. So when do we get all this functionality? When Java's program is run. And as the hardware kept getting updated from 1990s to now, the differentials between these two became very rare. Now it is so negligible that you won't even be able to tell the difference. That you have run a code in C + + or Java and you are saying that Java is slow. So if you make a language portable, then you will have to take a little trade-off and that trade-off was taken by Java using these many things, JIT compiler plus interpreter, right? So this is the thing, we understood what JVM does. So if I list down the functionality of JVM in some lines. So first of all, what is the work of JVM? Convert your bytecode to machine code. Now how to convert? Using interpreter plus your JIT compiler. We discussed this. Okay. And what else does JVM do? And we understood that JVM also provides you security using Sandbox model. Now what was this Sandbox model? We discussed this a little bit. What happens in this is that any of your Java bytecode, Now, because Java is a portable language, you can download bytecode from anywhere on the internet. And if you run it directly in your system and let's say it gets that unrestricted access, then it can do anything on your system. It can delete any file, it can place any virus, it can put Trojan horse, etc. Here, our JVM comes in use again. JVM provides you a safe environment, a restricted space to run your bytecode. So basically what happens is that our bytecode doesn't run directly on our system, our bytecode runs in JVM. And this closed space monitors whether the bytecode is asking for unrestricted access or not. It provides a protected environment. And finally, in this environment, our bytecode runs. And where is JVM itself? JVM is a virtual machine, not a real machine. So JVM exists in our system. Simple. So, what happens when bytecode is not run directly? It runs in our JVM and JVM does exist in our system. So, it provides us security in some way. Okay. Apart from this, if I say, what else does JVM provide us? So, there is one more third thing that JVM brings and gives us. That is garbage collection. Okay. So, the garbage collection of Java is in JVM. Now, what is garbage collection and when it is used, we will see that in the next lecture. Now, it will be a bit complex. But for now, you can assume that this is the work of JVM. Convert bytecode to machine code using interpreter, JIT compiler, security and garbage collection. Okay, we understood JVM very well. Java Virtual Machine. This means that if you have a Java Virtual Machine, Then you can convert any bytecode to machine code. Simple. So if I said that there is JVM on your system, then you can run any program of Java. But from where will you get bytecode? You don't have a compiler yet, which can bring that bytecode. Right? Means if you have written any source code in Java, then you will have to convert it to bytecode first. Right? So we have things above JVM. On top of that comes JRE, Java Runtime Environment. So JRE is nothing. JRE is like, you took JVM, and put Class Libraries in it. Class Libraries. Okay, what are Class Libraries? Class Libraries are nothing. If you want to run your Java program, okay? So you understand it like this, that whatever the source code of your Java is, whatever the source code of your Java is, you will do something in your source code. For example, you, you want to give some output on the console or you want to read something in the file or you want to perform any operation in which you will need the internal libraries of Java if you have ever read any programming language then you know that if I want to print some output on the screen then there are some internal methods and internal libraries of that language like in C, C + + I write Cout to print something on the screen. This is in C + +. I can write printf in C. Similarly, Java has a syntax to print something on the screen, to print something on the console. If you have never studied any programming language, it's okay, you can understand it this way. Because you want to print something on the console, you want to print something on the screen. then you will have to call the internal functions of Java or any language. You will have to pick up the internal libraries. Because you can't write everything in your code. You will only write your business logic. You will write whatever work you have to do. But how is the work happening from inside? That will be handled by the language. So all these operations, which a programming language does internally, we call them class libraries. Now in CC + +, you can consider whatever we include. hash include IO stream, etc. which are our pre-processor directives. Similarly, in Java, you can assume that we have some import statements in which we say that we want to import some inbuilt function of Java, we want to import some inbuilt library. Now if you have any doubt, then you will understand everything when we will write proper code in the next course. But now let's assume that some of the class libraries that we will use in our program are present in JRE. So JRE means JVM plus class libraries. Now if you have this thing, now you will be able to run any Java program properly. If you only had JVM, you wouldn't be able to run it properly. Because JVM didn't have class libraries, right? So if there was any part in the code where it wants to print something on the screen, then all that code comes from the class library and you don't have that. So it wouldn't be able to run it there. So you need at least one JRE to run any Java program properly. But interestingly, you can't have JVM alone. You can't even have JRE alone these days. You could have downloaded JRE earlier, but you can't even have JRE alone these days. You will have to go at least one step higher and you will have to install JDK, which we call Java Development Kit. So what is Java Development Kit? Now see. In java development kit, there is everything that you need to write a java code and to run it. So in your java development kit, there will be your JRE plus your compiler. Remember what we discussed in the starting that your source code needs a compiler to convert into byte code. So that will also be in your JDK. What else will happen? Your debugger. For those who don't know what debugger is, when we write code, we use debugger as well. Basically debugger helps us to break a code line by line and understand it. We basically stop a program in the middle to see what will be its output in this line. Then we move it forward and this is the use of debugger. If you don't understand, no problem, we will see it in depth later. So there is compiler, debugger and many more things like java docs. etc. etc. These are useful to write the documentation of Java. But we will use all the things later, so you don't need to think so much. Java Development Kit, you must be understanding from the name itself that this is a complete package to run your Java program. If you have JDK installed in your system, then what can you do? If you have JDK installed, then you can run any Java source code Write it on any editor, okay? For that, you can put any IDE like IntelliJ, VS Code. And if you want to write text in Notepad, then you can do that too. Obviously, you will do that for small programs. For big programs, you will need an IDE. So, you wrote something for Java once. Now, because you have installed JDK, and your compiler comes inside JDK, now you will be able to convert your source code to bytecode. Okay? Now, because you have JRE as well, in which you have JVM and you have class libraries, you will be able to convert this bytecode using JVM in your machine code. Okay? So, you can do this entire process using Java Development Kit. Right? So, the diagram we saw in the starting, this one of concentric circles. Okay? So now you will understand better that first comes JVM, then JRE and then JDK So now if you have JDK installed, you can run any program. So now I hope you have understood all the things like JDK, JRE and JVM. Now your job is to install JDK on your system. So you don't have to do anything. Install the latest JDK. Either you can do it directly from the Oracle website. Or there are many other ways. You can do it from Home Preview. There are many ways. Now I will not download this with you. Now brother... Ask chat GPT, ask cloud, google, you will understand how to install it. Install JDK, see what things it takes to install it, then only you will learn from yourself. You will have to set some path variables, but as soon as you google it, you will understand. I want you to prepare your system page in your laptop, wherever you are watching this video. As soon as we start writing a Java program, your program should run. Now we will write Java code. Pause this video if you want. Now go and install JDK. Install the latest version, the stable version. You have to see the process. You have to google it. Ask GPT, but be careful. I assume that you have installed JDK on your system. Now you are ready to code. But before that, we will discuss 2-3 more things. This is important. Many times, we are asked, what is JSE? What is JWE? And what is JME? These are some terms. Many people get confused in this. But actually it is very simple. Let's write their full form once. So look, JSE means Java Standard Edition. JWE means Java Enterprise Edition. And JME means Java Micro Edition. These are nothing but different standards of Java. When Java was created, which we also call Core Java. So that is our JSE. JSE. is our core Java. Basically, you can do everything in this. All the things that are in Java, like OOPs principles, class methods, you can write anything. Everything Java, whatever you want to learn in Java, you cover everything in Java's standard edition, which we call core Java. But when Java started to be used a lot, then it became clear that Java's use is not only in core Java, basically in writing small programs, You can use Java to create websites and web apps. That's when JEE was born, which we call Java Enterprise Edition. Enterprise Edition means that we added new things, libraries and classes to Java. that you can use Java to create websites, web apps. So, some new methods were introduced in this. So, when we finish core Java, then we will see what are the methods in enterprise edition so that we can use Java in web apps or when we will read Spring Boot, then you will understand well which are the libraries and methods that we use. If I tell you something in this, then those who have a little idea will understand. Transactionals. It comes in this. Your. Those who don't know. No problem. We will read it normally. Okay. There are many more methods. Which come in your Java Enterprise Edition. Okay. Just remember. This Java Enterprise Edition. We also call Jakarta EE. Many times you must have heard this name. Jakarta EE. Its name is Jakarta EE these days. So remember that too. Jakarta Enterprise Edition. Okay. Simple. And this last one. This. JME. which we call Java Micro Edition. This is nothing. Just understand it like this, that Java has a lightweight edition. Lightweight. What used to happen is that in the earlier times, when mobile phones were made, early mobile phones, in which there were Java applications, you must have seen those small mobile phones in your homes, the applications that were made in those were made using JME, Java Micro Edition. Now, it has become very obsolete. We don't use it. You must have understood who replaced it. These days mobile apps are made through android which you can code in java or kotlin and kotlin is also java based if you understand. So basically android replaced GME so nowadays GME is not used anywhere so there is no need to read it. We will focus on core java first and when we will finish core java After that we will focus on JEE which is java enterprise edition In which we will understand that we have to make websites using java If we want to use spring boot then java has given us many new things So this is the complete architecture Now I hope you have installed JDK quickly Your system will be ready to write code Now let's see our first Java simple code and try to run it. Before that, let me tell you something. Let's say we are going to write a code in a text editor. Let's say I will keep the name of that file. demo.java. Okay. So, I am telling you that we are about to do it. Now, obviously, we can open a text editor or we can open an IDE. Integrated Development Environment. You know that. Either we can open VS code or we can prefer IntelliJ, anything. For this lecture, I will open VS code. I will make a file demo.java and write a simple code of Java in it. We will not go into the syntax of Java now, we will see that in the next lecture. Now we will just understand how to run Java. So what we will do is, first of all we will make a file demo.java and write a simple Java code in it. After that, we will run this file through the compiler. Now, because we have installed JD, so we must have got the compiler. We will run it through the compiler and generate bytecode. And you know, we discussed in the last lecture, if your file's name is demo.java, then the bytecode file that will be generated, its name will be demo.class. It will be generated automatically, we will see that. Okay. If we want to convert it to byte code through compiler then we have a command javac file name demo.java Let's write it a little properly. So here we will use javac demo.java and our file will be compiled and converted to byte code. Once we get the bytecode, now we have to run the bytecode and that works as JVM and KIA uses class libraries which actually works as JRE. Now JRE will make our machine code. which means it will convert it to 0s and 1s. Now this is not visible to us, it is inside the system. Who will read the machine code? Our CPU will read the machine code, which means our processor will read it. And what will it give us after reading it? It will give us an output and that output will be visible to us on our screen. So we have to do this. And as I told you about its command, if you want to compile, if you get the bytecode, to run this bytecode, we have a command. Let's write it in orange, java demo. Basically, your keyword is java and then the name of the file. After that, as soon as you write this, your file will start running. And from inside, we know, we discussed what will be happening. In JRE, you have JVM which will use interpreter and your JIT compiler will use and by combining these two your source code not source code your byte code will slowly convert into machine code which will be used more frequently that JIT compiler And the less frequent code, the interpreter will transform it line by line. Converting it in machine code, it will give output to the CPUs. So we have to do all this. Let's see it quickly. So first of all, you can see on the screen that I have opened my VS code. There is nothing in it. In this, I have opened an empty folder, java first program. And here I make a file, as we discussed, in the name of demo.java. As soon as I created the file, it generated some code by itself. This is just a VS Code feature. This is just a boilerplate code. It generates the template we need. Don't pay attention to this. And don't even focus on what I am writing if you are reading Java for the first time. Because these keywords will be too much for you. Now you just have to focus on how we run a Java program. So we have written a basic program. Now, I want to print something on the screen. So, I called system.out.println. We all will read about it. And let's say I printed hello world on the screen. Simple. So, this program is nothing. We will go inside this program. What is class? What is static keyword? What is public? Void? Main? What are these string args? And what have we written here? System.out.println Finally, you just have to understand this much. By doing all this, we will print this character on the hello world screen. Okay? So I saved it. Now see, here I can open the terminal of my Mac by doing this. Okay? Same if you have a Mac, you can open your terminal. If you have a Windows, you can open the command prompt. But what did I do? I directly opened the terminal in its view. Because it also has its own terminal. Okay? Now see, Here in the terminal, which folder am I in? Java 1st Program, right? In which my file is demo.java, which we discussed. Now what I have to do is compile this file. And the compile command was javac demo.java. Now see, as soon as I press enter, this compiler, which has JDK install in it, that compiler will compile my file and convert it to bytecode. And here a new file will be created in the name of demo.class. See, demo.class is created and our code has been compiled. Now if I open this demo.class, you will see the same code again. Why? Because VS code, whenever it sees a file with the extension. class, it tries to decompile it back to the source code. So if I open it, you will see that the source code is decompiled from a. class file. using fernflower decompiler. So it used fernflower decompiler and gave us the source code again. It added a little more code to it, but leave that for now. Just assume that it doesn't look like a. class file. It has tried to decompile it. Otherwise, if you open the. class file, you won't understand anything. Because it is an intermediate file. Neither it will be in English, nor it will be proper machine code. It will be an intermediate code. So what did I do? I generated the. class file. By writing this. Now I want to run this program, basically I want hello world output on the screen So our bytecode has been generated, now JVM converts bytecode into machine code For that command is javademo, whatever is the name of the file Now as soon as I press enter, our code will be converted into machine code Which will run the CPU and will give us the output, as soon as I press enter, we got the output of hello world So this is how we ran our first Java program, we saw its skeleton and saw what is actually happening behind the scenes. We went in-depth for everything, what is JVM, what is JRE, what is JDK and how things work behind the scenes. It is very important to understand how everything works from the very first line of code to our output. If you understand this, you will be very different from the rest of the people who just remember the syntax and they don't know how things are working from within. Right. I hope you enjoyed it. If you haven't installed JD, then please do it. When we start writing code from the next lecture, then it will be very useful. For the rest of this playlist, I have made a new GitHub repository. Okay. You keep checking it. I will always attach it in the description. In that, some questions will be ready for you. And I want you to do those questions. Solve those questions yourself. Don't try to do chat, gpd or google. Until you get stuck. Try to remove things from yourself. Put first thought principle. You will enjoy learning. See you in the next lecture. Till then, thank you so much.
