What is the difference between JDK and JRE?

2018-12-31 07:13发布

What is the difference between JDK and JRE?
What are their roles and when should I use one or the other?

标签: java
20条回答
无色无味的生活
2楼-- · 2018-12-31 07:37

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.

查看更多
爱死公子算了
3楼-- · 2018-12-31 07:37

If you want to run Java programs, but not develop them, download the Java Run-time Environment, or JRE. If you want to develop them, download the Java Development kit, or JDK

JDK

Let's called JDK is a kit, which include what are those things need to developed and run java applications.

JDK is given as development environment for building applications, component s and applets.

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.

查看更多
初与友歌
4楼-- · 2018-12-31 07:38

Jvm, Jre, Jdk these are all the backbone of java language. Each components work separately . Jdk and Jre physically exists but Jvm is an abstract machine that means it has not physically exists.

JVM is subsystem of JDK and JRE which use to check intermediate code knows as Bytecode. It first load "class file" having .c extension generated by Java compiler (Javac) through JVM subsystem classloader and classified memory location (class area, stack, heap and pc registers) according to there use. Then check all Bytecode to ensure that it is return in java and all memory accessibility access by the network. After that interpretor work start, interpretor check whole program line wise line and finally result shown in console, browser and application through JRE (Java Runtime Environment) which runtime facilities.

JRE is also a subsystem of JDK which provide runtime facilities like JVM, classes, executable file like .jar file etc.

JDK stands Java Development Kit it contain all necessary components which used in programming like class, methods, swing, AWT, package, java (interpretor), javac (compiler), appletviewer(applet application viewer) etc. So final conclusion is it content every file which useful in developing an application weather it standalone or web based.

查看更多
春风洒进眼中
5楼-- · 2018-12-31 07:39

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.

查看更多
妖精总统
6楼-- · 2018-12-31 07:39

A clear understanding of these terms(JVM, JDK, JRE) are essential to grasp their usage and differences.

JVM Java Virtual Machine (JVM) is a run-time system that executes Java bytecode. The JVM is like a virtual computer that can execute a set of compiled instructions and manipulate memory locations. When a Java compiler compiles source code, it generates a highly optimized set of instructions called bytecode in a .class file. The JVM interprets these bytecode instructions and converts them to machine-specific code for execution.

JDK The Java Development Kit (JDK) is a software development environment that you can use to develop and execute Java applications. It includes the JRE and a set of programming tools, such as a Java compiler, interpreter, appletviewer, and document viewer. The JDK is implemented through the Java SE, Java EE, or Java ME platforms.

JRE The Java Runtime Environment (JRE) is a part of the JDK that includes a JVM, core classes, and several libraries that support application development. Though the JRE is available as part of the JDK, you can also download and use it separately.

For complete understanding you can see my Blog : Jdk Jre Jvm and differences

查看更多
人气声优
7楼-- · 2018-12-31 07:40

Here's a simple response directly from Oracle http://docs.oracle.com/javase/7/docs/technotes/guides/

Java SE Runtime Environment (JRE)

The JRE provides the libraries, Java virtual machine, and other components necessary for you to run applets and applications written in the Java programming language. This runtime environment can be redistributed with applications to make them free-standing.

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.

查看更多
登录 后发表回答