Why Java compiler as distributed as executable and not as JVM bytecode?

后端 未结 1 1252
谎友^
谎友^ 2021-01-19 09:56

In the answer Platform independence in Java ByteCode, it is said that Java Compiler is same across all the platforms. I do understand that.

My question is that why

相关标签:
1条回答
  • 2021-01-19 10:49

    javac.exe (on my installation, JDK 1.8 on Windows x64) is about 15K in size. This isn't the full compiler. The compiler itself really is written in Java, and javac.exe is just a launcher, effectively. This is true of many of the tools that come with Java - it would be a pain to have to run something like:

    java -cp path/to/javac.jar java.tools.Javac -cp path/to/your/libraries Foo.java
    

    for example.

    0 讨论(0)
提交回复
热议问题