everyone welcome back to java one for all and in this video we are going to talk about how java works well it's pretty straightforward uh we could go on and on how it works behind the scenes but it's just an introduction we have more than 200 videos that i'm going to cover a lot of details and this is what we need to get started so let's go to draw that io and let's put some shapes here so let's start drawing some boxes what doesn't like boxes we have a couple operating systems so for example we have windows we have linux and we also can add here uh mac os for example so i hope at this point you are a bit familiar uh how like software development works what is software what is a computer what is harder and things that you do on daily basis because this is how it works we usually have our computer so we can even draw a computer here i will drop computer here imagine that this is a computer so your computer it's a set of hardware we have hard drive we have processor we have memory and we have pco and so on so these components they need to be managed and the software responsible for this management are the operating systems windows linux mac and so on so when way way way back then we were developing uh applications we used to develop applications directly to the operating system so for example have you ever seen those dot exe applications so for example powerpoint when you are installing you have the dot exe from exactly and this is what represents usually the windows applications if you try to run that on linux it will not work you need to virtualize it's a process like you are simulating as you are in windows but inside an operating system that's linux and the same for mac os that the extension of the software is usually dmg dsa database so how it used to work we used to have uh apps so i will draw another box here this one so imagine that i'm developing one app that was in 1988 that's the i was born not the year i was developing software we used to have different types of app one app to run on windows and another app even if it's the same app to run on linux and also this same app like doing the same thing the same functionalities but in different programming languages so this one could be for example uh let's say c uh c plus plus or this one could be um python didn't exist back then i don't know maybe cabal and so on so we have different types of programming languages and back then you were developing your software to run directly into the operating system so basically it was one-to-one relationship between your app and the operating system so the java guys when they were developing they thought well wouldn't be nice if we could write most and run everywhere and that's why we have this slogan that is still used to this day uh when we talk about java when we say run write once and run everywhere it means that we are trying to use the same language the same piece of code the same source and just executing different operating systems so how can we achieve that let's use an analogy if you are an english speaker and you would like to talk to someone that only speaks japanese how can you achieve that so one way is hiring a translator a professional translator that can both understand english and japanese so he will have input in two different ways and he will do this uh translation for you and you will be able to talk to the person that's the only japanese speaker and the japanese speaker will be able to talk to you that's only english speaker so thinking about this analogy this is what's happening with java so java is one powerful language because we have something in between that will do this for us so there is a layer here the best way to solve this problem is like writing a layer that will go on top of the operating systems so this layer it is an application and this application is responsible for understanding what my app is saying and talking to the operating system and this is called jvm java virtual machine so basically java virtual machine it is an application that can understand what the app that i'm developing that's using the extension. java we are going to go into details in a moment and can talk to the operating operating system basically machine code so the java virtual machine can talk to these guys and my app java will talk to the java virtual machine but willen are you saying that the java virto machine is one application that i can install in the different operating systems no the java virtual machine and when we do that in the next video when you're trying to download you have to download the java virtual machine specifically for your operating system so you have a jvm for windows linux mac solaris and so on so you download the virto machine that can understand your operating system but the code that you are going to develop here can be executed in any of the operating systems that has a java virtual machine so basically the input here we'll always understand your code but the output will depend on the java virtual machine you just downloaded so you're basically saying we know that i can get my java application here and send directly to the java virtual machine no actually we need a couple more steps so the dot java class is what we call the file is only for us as humans to understand what is happening so this is basically what we call a language high-level language that can uh be understood by humans so if i get a class a java file and i give it to someone even if they are not developers they will at least be able to read and they will be able to tell something about that code if you write a good code and you are watching this video you will be able to write a good code they even be uh probably will be able to tell what this code is going to do so this is the higher level and uh when we go to low level we are going more towards the uh operating system so the more low level the the code is the language is the better performance because it will be writing directly basically to the operating system but it's way more difficult so what we have to do here is the java virtual machine will not understand the dot java extension so there is a process in between so we say that java is a compiled language what does it mean compiled it means that it will get the code that you wrote and it will pass through some transformation and this transformation it's basically compiling so your app dot java will become this app dot class what this class means this means that this file. java was compiled and then this became a bytecode so basically this app1.
java became through compilation and app1. class this is the bytecode and the bytecode is what the java work machine can understand so the java virtual machine will always understand only the byte code and the bytes code is something that's not easily readable by humans i'm going to show that in the next video but it's pretty complex so how do we actually run how do we execute so we have a couple ways of doing this when we are talking about software development we want to develop applications with java we are going to uh run a java development kit so basically there are two ways a java development kit and java runtime environment so if you are only going to execute technically you just need the java runtime environment installed but if you're going to develop you need a java development kit this kit will have for example something that we can use to compile that's called java c and there are other things for example uh the bug that we can also use and we are going to see throughout this course so there are two options both of them they do have a java virtual machine but we are not going to install gre because the jdk will have a gre and we are going to focus only on the development kit so this is the big picture of java what you need to take from this class is that you have your source code that's dot java it's going to be compiled into a byte code called the same name of your file but instead of java.