What is the role of the OS when JVM executes a Java application? And why do we need the OS?

后端 未结 6 416
一生所求
一生所求 2021-02-01 22:30

I have done some reading on the internet and some people say that Java application is executed by the java virtual machine (JVM). The word \"execute\" confuses me a little bit.

6条回答
  •  孤独总比滥情好
    2021-02-01 23:00

    We need the OS for all the things a C or C++ program would. The JVM does a few more things by default, but it doesn't replace anything the OS does. The only difference might be that sometimes you have Your Code [calls the] JVM [calls the] OS, or with compiled code you can have Your Code [calls the] OS

    Similarly in C++ you might have Your Code [calls the] Boost [calls the] OS.

    When your program is running in native code, it doesn't need the JVM as such. This is good because the JVM knows when to "stand back" and let the application run. However, not all the program will be compiled to native code for the rest of the life of the application, so you still need it.

    Its is possible to use kernel by-pass devices/drivers with JNI, but Java doesn't directly support this sort of feature.

提交回复
热议问题