How does JVM, Java, JDK and JRE work?

Can Java compile to .exe?

All operating system, such as Windows, MacOS, Linux, etc. already comes with the JVM installed to interpret the program made in Java? Or when compiling the program b.exe already comes with the built-in JVM?

Why to use a Java program needs JRE, and to develop it needs a JDK?

Author: Maniero, 2020-04-22

1 answers

Can Java compile to .exe?

Java is a programming language so it doesn't define that kind of thing. A language-specific implementation can generate a .exe and in fact some do, but not the most common one that people use.

And generating a .exe only makes sense even on Windows, right? It's a bit more complicated than that, but to simplify it would be so.

If you want to know if the compiler generates a binary file that is capable of being executed in some way, so yes, the .class is that file (it also has the .jar). The extension does not define whether it can be run, defines, conforms to the content within a specific binary format that some operating systems understand.

If you want to know if it generates a native binary that runs directly on the processor, then this .class is not so, it is a bytecode that will be JITtado.

There is implementation that have an intermediate binary, similar to .class, but a little different and when it is installed a native binary is generated for the operating system to run directly.

You can see more in What is the difference between compiled language to interpreted language?.

I think it is a little out of date: programming language that does not require prior installation (at the time all implementations run in a similar way and required an environment mounted).

All operating system, such as Windows, MacOS, Linux, etc. already comes with the JVM installed to interpret the program made in Java? Or when compiling the program b.exe already comes with the built-in JVM?

Operating systems don't usually come with JRE installed (Android is an exception, but it's not the standard JRE that's on it, it has ART). For the most common form of Java need to install it before using. But as it was said before has Implementation that the runtime can be next to your application, there you do not need to install anything beforehand.

Java is not interpreted .

Why to use a Java program needs JRE, and to develop it needs a JDK?

JDK is the Java SDK, you can see in What is an SDK?. The Java Runtime Environment (JRE) is the installed environment where you have runtime and what you need for the application to run.

Maybe this will help: what does "run on the JVM" mean?.

Although .NET helps explain what is the runtime , the details are different, but the idea is the same: what is really the "runtime environment"?

May seem confusing and an answer may help: after all, is Java a platform or a programming language?.

May interest: relationship between hotspot and JVM, JDK / OpenJDK? and what is Grailvm?.

 6
Author: Maniero, 2020-04-22 11:22:53