What is the difference between JDK and JRE?

前端 未结 20 1648
孤独总比滥情好
孤独总比滥情好 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:04

    If you are a Java programmer you will need JDK in your system and this package will include JRE and JVM as well but if you are normal user who like to play online games then you will only need JRE and this package will not have JDK in it.

    JVM

    JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed.

    JVMs are available for many hardware and software platforms. JVM, JRE and JDK are platform dependent because configuration of each OS differs. But, Java is platform independent.

    JRE

    It contains everything you need to run Java applications in compiled form. You don't need any libraries and other stuffs. All things you need are compiled.

    JRE is can not used for development, only used for run the applications.

    Java SE Development Kit (JDK)

    The JDK includes the JRE plus command-line development tools such as compilers and debuggers that are necessary or useful for developing applets and applications.

    (Sources: GeeksForGeeks Q&A, Java Platform Overview)

    0 讨论(0)
  • 2020-11-22 04:06

    JRE

    JRE is an acronym for Java Runtime Environment.It is used to provide runtime environment.It is the implementation of JVM.It physically exists.It contains set of libraries + other files that JVM uses at runtime.

    JDK

    JDK is an acronym for Java Development Kit.It physically exists.It contains JRE + development tools.

    Link :- http://www.javatpoint.com/difference-between-jdk-jre-and-jvm

    Usually, when you only care about running Java programs on your browser or computer you will only install JRE. It's all you need. On the other hand, if you are planning to do some Java programming, you will also need JDK.

    0 讨论(0)
  • 2020-11-22 04:08

    One difference from a debugging perspective:

    To debug into Java system classes such as String and ArrayList, you need a special version of the JRE which is compiled with "debug information". The JRE included inside the JDK provides this info, but the regular JRE does not. Regular JRE does not include this info to ensure better performance.

    What is debugging information? Here is a quick explanation taken from this blog post:

    Modern compilers do a pretty good job converting your high-level code, with its nicely indented and nested control structures and arbitrarily typed variables into a big pile of bits called machine code (or bytecode in case of Java), the sole purpose of which is to run as fast as possible on the target CPU (virtual CPU of your JVM). Java code gets converted into several machine code instructions. Variables are shoved all over the place – into the stack, into registers, or completely optimized away. Structures and objects don’t even exist in the resulting code – they’re merely an abstraction that gets translated to hard-coded offsets into memory buffers.

    So how does a debugger know where to stop when you ask it to break at the entry to some function? How does it manage to find what to show you when you ask it for the value of a variable? The answer is – debugging information.

    Debugging information is generated by the compiler together with the machine code. It is a representation of the relationship between the executable program and the original source code. This information is encoded into a pre-defined format and stored alongside the machine code. Many such formats were invented over the years for different platforms and executable files.

    0 讨论(0)
  • 2020-11-22 04:08

    JRE

    JRE is an acronym for Java Runtime Environment.It is used to provide runtime environment.It is the implementation of JVM. It physically exists. It contains set of libraries + other files that JVM uses at runtime.

    Implementation of JVMs are also actively released by other companies besides Sun Micro Systems.

    JDK

    JDK is an acronym for Java Development Kit.It physically exists.It contains JRE + development tools.

    0 讨论(0)
  • 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.
    0 讨论(0)
  • 2020-11-22 04:11

    JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed.

    JRE is an acronym for Java Runtime Environment.It is used to provide runtime environment.It is the implementation of JVM.It physically exists.It contains set of libraries + other files that JVM uses at runtime

    JDK is an acronym for Java Development Kit.It physically exists.It contains JRE + development tools

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