Java可以编译没有JVM的源代码吗?

时间:2023-01-18 23:44:19

I am searching about JVM in detail to understand the working of it and to work properly with Java programming language so, how much JVM is important for java compilation except Operating system independent.

我正在详细搜索JVM以了解它的工作情况并使用Java编程语言正常工作,因此,除了独立于操作系统之外,JVM对Java编译有多重要。

3 个解决方案

#1


3  

If using the primary compiler, Javac, you'll need a JVM.

如果使用主编译器Javac,您将需要一个JVM。

The JVM does not affect compilation, it's only needed because the primary compiler is actually a Java program itself, and a JVM is needed to run Java programs.

JVM不会影响编译,只需要它,因为主编译器本身就是一个Java程序,运行Java程序需要一个JVM。


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

从理论上讲,编译器是编译Java代码所需要的唯一东西。事实上,JVM对Java编程语言一无所知,只知道编译器生成的字节码。 JVM允许您的计算机运行Java程序,并且不会影响编译过程。

However, Java's primary compiler was written in Java. To run the primary compiler, you need a JVM.

但是,Java的主要编译器是用Java编写的。要运行主编译器,您需要一个JVM。

If you used a compiler written in a different language, you wouldn't need the JVM to compile code.

如果您使用以不同语言编写的编译器,则不需要JVM来编译代码。

#2


-3  

JVM does not compile the code, it interprets.

它解释了JVM不编译代码。

Java is both an interpreted and compiled language. The Java compiler ,'Javac' produces byte-code which is platform-independent. This byte-code is, we can say generic, ie., it does not include machine level details, which are specific to each platform. The instructions in this byte-code cannot be directly run by the CPU. Therefore some other 'program' is needed which can interpret the code, and  give the CPU machine level instructions which it can execute. This program is the 'JVM' (Java Virtual Machine).  Note that the JVM is platform specific.

Java既是解释语言又是编译语言。 Java编译器'Javac'生成与平台无关的字节码。这个字节码,我们可以说是通用的,即,它不包括特定于每个平台的机器级细节。该字节码中的指令不能由CPU直接运行。因此,需要一些其他“程序”来解释代码,并提供可以执行的CPU机器级指令。该程序是'JVM'(Java虚拟机)。请注意,JVM是特定于平台的。

#3


-3  

The JVM has nothing to do with compiling java code. The JVM is purely responsible for running already compiled code. There exists lots of software for compiling java code, for example, the javac compiler included in the JDK, or the integrated compilers in most IDE's, and there are seperate compiling tools such as gradle or ant.

JVM与编译java代码无关。 JVM完全负责运行已编译的代码。有很多用于编译java代码的软件,例如JDK中包含的javac编译器,或者大多数IDE中的集成编译器,还有一些单独的编译工具,如gradle或ant。

#1


3  

If using the primary compiler, Javac, you'll need a JVM.

如果使用主编译器Javac,您将需要一个JVM。

The JVM does not affect compilation, it's only needed because the primary compiler is actually a Java program itself, and a JVM is needed to run Java programs.

JVM不会影响编译,只需要它,因为主编译器本身就是一个Java程序,运行Java程序需要一个JVM。


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

从理论上讲,编译器是编译Java代码所需要的唯一东西。事实上,JVM对Java编程语言一无所知,只知道编译器生成的字节码。 JVM允许您的计算机运行Java程序,并且不会影响编译过程。

However, Java's primary compiler was written in Java. To run the primary compiler, you need a JVM.

但是,Java的主要编译器是用Java编写的。要运行主编译器,您需要一个JVM。

If you used a compiler written in a different language, you wouldn't need the JVM to compile code.

如果您使用以不同语言编写的编译器,则不需要JVM来编译代码。

#2


-3  

JVM does not compile the code, it interprets.

它解释了JVM不编译代码。

Java is both an interpreted and compiled language. The Java compiler ,'Javac' produces byte-code which is platform-independent. This byte-code is, we can say generic, ie., it does not include machine level details, which are specific to each platform. The instructions in this byte-code cannot be directly run by the CPU. Therefore some other 'program' is needed which can interpret the code, and  give the CPU machine level instructions which it can execute. This program is the 'JVM' (Java Virtual Machine).  Note that the JVM is platform specific.

Java既是解释语言又是编译语言。 Java编译器'Javac'生成与平台无关的字节码。这个字节码,我们可以说是通用的,即,它不包括特定于每个平台的机器级细节。该字节码中的指令不能由CPU直接运行。因此,需要一些其他“程序”来解释代码,并提供可以执行的CPU机器级指令。该程序是'JVM'(Java虚拟机)。请注意,JVM是特定于平台的。

#3


-3  

The JVM has nothing to do with compiling java code. The JVM is purely responsible for running already compiled code. There exists lots of software for compiling java code, for example, the javac compiler included in the JDK, or the integrated compilers in most IDE's, and there are seperate compiling tools such as gradle or ant.

JVM与编译java代码无关。 JVM完全负责运行已编译的代码。有很多用于编译java代码的软件,例如JDK中包含的javac编译器,或者大多数IDE中的集成编译器,还有一些单独的编译工具,如gradle或ant。