初识JVM--从Java文件到机器指令
前言
Java自1996年发展至今,已经不仅仅是一种语言,还是一种标准,只要写出满足JVM规范的class字节码文件,就可以在JVM执行。通过JVM屏蔽了上层语言的不同和底层操作系统的区别。实现了一次编写,处处运行
一、编写Java文件
我们写一段比较简单的Java代码
public class HelloJVM { public static void main(String[] args) { String helloJVM=\"hello JVM\"; hello(helloJVM); } public static void hello(String word){ System.out.println(word); }}
二、编译
Java文件由JDK提供的Javac工具,编译为字节码文件
什么是字节码文件
今天先写到这里