当前位置:网站首页>JVM's responsibility - load and run bytecode

JVM's responsibility - load and run bytecode

2022-07-05 01:42:00 A bowl of humble powder

One 、JVM Responsibility for

        JVM It exists in JRE Medium , Bytecode must depend on JVM To run , It is running all Java The virtual computer of the program .JVM It's not cross platform ,JVM Our responsibilities mainly include two parts :

        (1) Load the specified bytecode file

        (2) Load the bytecode file into memory to run

 

Two 、JVM function class An example of 《 memoir 》

Remember the first one HelloWord Do you ?

1、 New text document , The name for HelloWord.java


2、 Enter the following code ( Use Editplus or Notepad++)

class Hello {
    public static void main(String[] args) {
        System.out.println(" elder male cousin ! I came out !!");
    }
}


3、 Open command window


4、 Use javac Tools , Yes HelloWord.java File compilation operation :javac file name .java

 

5、 After compilation , Will generate HelloWord.class file ( If compilation fails , No bytecode file is generated )

6、 start-up JVM, And load HelloWord This bytecode and execute , Grammar is :java Class name

【 Be careful 】 The command to run is java Hello , It's not java HelloWord.class 
Run class Hello There must be main Method


【1】JRE:Java Runtime Environment,Java Running environment
【2】JDK:Java Development Kit,Java development tool ( Including development Java All tools of the program, such as javac and java etc. ,JDK contain JRE
【3】JVM:Java Virtual Machine,Java virtual machine
原网站

版权声明
本文为[A bowl of humble powder]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141019310822.html