正如它的标语所说:编写一次,随处运行。 人们喜欢Java的一个重要原因就是Java Virtual Machine保证了同样的代码可以在不同的平台运行。
Java是一门编译语言,意味着.java会先被编译器转成字节码,然后再由虚拟机执行。 Java is a compiled programming language, meaning the code we write in a .java file is transformed into byte code by a compiler before it is executed by the Java Virtual Machine on your computer.
基本的过程是: 1 运行javac命令将Java文件编译为class文件
javac Plankton.java️
2 成功的编译生成class文件Plankton.class 我们再运行java 执行命令
java Plankton
Note that we leave off the .class part of the filename.