Can Java compile source code without JVM?

I understand the JVM in detail to understand its operation and work correctly with the Java programming language, therefore, how important is the JVM for compiling java, besides being independent of the operating system.

+4
source share
3 answers

If you are using the primary compiler, Javac , you will need a JVM.

The JVM does not affect compilation, this is only necessary because the main compiler is actually the Java program itself, and a JVM is required to run Java programs.


Theoretically, a compiler is the only thing you need to compile Java code. In fact, the JVM knows nothing about the Java programming language , only bytecode generated from compilers. JVM allows your computer to run Java programs and does not affect the compilation process.

However, the primary Java compiler was written in Java. To start the main compiler you need a JVM.

If you used a compiler written in another language, you do not need a JVM to compile the code.

+2
source

JVM does not compile code, it interprets.

Java . Java "Javac" -, . -, , , .. , . . - "", , . "JVM" ( Java). , JVM .

-3

JVMhas nothing to do with compiling java code. JVMbears full responsibility for running already compiled code. There are many programs for compiling java code, for example, the compiler javacincluded in JDKor integrated compilers in most IDEs, and there are separate compilation tools such as gradleor ant.

-3
source

Source: https://habr.com/ru/post/1655876/


All Articles