What is the difference between JDK and JRE?

前端 未结 20 1626
孤独总比滥情好
孤独总比滥情好 2020-11-22 03:31

What is the difference between JDK and JRE?

What are their roles and when should I use one or the other?

20条回答
  •  抹茶落季
    2020-11-22 04:11

    The answer above (by Pablo) is very right. This is just additional information.

    The JRE is, as the name implies, an environment. It's basically a bunch of directories with Java-related files, to wit:

    • bin/ contains Java's executable programs. The most important is java (and for Windows, javaw as well), which launches the JVM. There are some other utilities here as well, such as keytool and policytool.
    • conf/ holds user-editable configuration files for Java experts to play with.
    • lib/ has a large number of supporting files: some .jars, configuration files, property files, fonts, translations, certs, etc. – all the "trimmings" of Java. The most important is modules, a file that contains the .class files of the Java standard library.
    • At a certain level, the Java standard library needs to call into native code. For this purpose, the JRE contains some .dll (Windows) or .dylib (macOS) or .so (Linux) files under bin/ or lib/ with supporting, system-specific native binary code.

    The JDK is also a set of directories. It is a superset of the JRE, with some additions:

    • bin/ has been enlarged with development tools. The most important of them is javac; others include jar, javadoc and jshell.
    • jmods/, which holds JMOD files for the standard library, has been added. These files allow the standard library to be used with jlink.

提交回复
热议问题