如何编译和运行java程序? [英] how is a java program compiled and run?
问题描述
这个问题非常广泛,但我想深入了解......我可以编写和运行java程序,但仍然让我困惑的是如何实现整个程序。我们有编译器来转换程序到JVM的字节码。 JVM如何分配内存? JVM是否具有内置堆和堆栈,或者JVM的解释器是否将内存分配给主内存本身中的对象。
请原谅我的无知......但这真让我感到困惑。
The question is very broad , but i wanted to go under-the-hood..I can write and run java programs,but still what puzzles me is how the overall program is implemented.We have the compiler which converts the program into bytecode for the JVM. And how does the JVM allocate memory ? Does JVM have a built in heap and stack or does the interpreter of the JVM allocate memory to the object in the main memory itself. Forgive me for my ignorance...but this really puzzles me.
提前致谢..
Sriram
Thanks in advance.. Sriram
推荐答案
-
.java
文件是从人类可读形式转换而来的到字节代码
使用Java编译器
。.java
file is converted from human readable form tobyte code
usingJava Compiler
.JVM
加载类(在初始化之前加载)。JVM
loads the class (loading is done before initialization).JVM
还要关注创建
和管理
字符串文字
在此期间。JVM
also take care about thecreation
andmanagement
ofString Literals
during this time.当
类$ c时$ c>被实例化,
。实例
被JVM
赋予内存空间heap
,以及hashCode
,这取决于<$ c $指定的内存位置 c> JVMWhen the
class
is instantiated, theinstance
is given memory space byJVM
on theheap
, along withhashCode
, which depends on the memory location assigned byJVM
.这篇关于如何编译和运行java程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!