如何编译和运行java程序? [英] how is a java program compiled and run?

查看:110
本文介绍了如何编译和运行java程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题非常广泛,但我想深入了解......我可以编写和运行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 to byte code using Java Compiler.

      JVM 加载类(在初始化之前加载)。

      JVM loads the class (loading is done before initialization).

      JVM 还要关注创建管理 字符串文字在此期间。

      JVM also take care about the creation and management of String Literals during this time.

      被实例化,实例 JVM 赋予内存空间 heap ,以及 hashCode ,这取决于<$ c $指定的内存位置 c> JVM

      When the class is instantiated, the instance is given memory space by JVM on the heap, along with hashCode, which depends on the memory location assigned by JVM.

      这篇关于如何编译和运行java程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆