Why use JRE?
Here are the important reasons of using JRE:
- JRE contains class libraries, JVM, and other supporting files. It does not contain any tool for Java development like a debugger, compiler, etc.
- It uses important package classes like math, swingetc, util, lang, awt, and runtime libraries.
- If you have to run Java applets, then JRE must be installed in your system.
How JRE Functions?
JRE has an instance of JVM with it, library classes, and development tools. Once you write and compile Java code, the compiler generates a class file having byte code.
Here are the important components of JRE:
- Class loaders: The class loader loads various classes that are necessary for running a Java program. JVM uses three class loaders called the bootstrap class loader, extensions class loader, and system class loader.
- Byte code verifier: Byte code verifier verifies the bytecode so that the code doesn’t disturb the interpreter.
- Interpreter: Once the classes get loaded, and the code is verified, the interpreter reads the code line by line.
- Run-time: Run-time is a system used mainly in programming to describe time period during which a particular program is running.
- Hardware: Once you compile Java native code, it runs on a specific hardware platform.
In this way, the Java program runs in JRE.
Java Development Kit (JDK)
Java JDK is the software bundle using which the Java applications can be developed. JDK’s main component is the Java compiler using which the Java source code is compiled to byte code. Along with the Java compiler it contains more tools like Jar, JConsole, Javaw, etc. These help tools help in various different aspects of developing a Java application. The JDK bundle can be downloaded from the above given link in Oracle’s website.
Runtime Enviroment là gì?
Một chương trình phần mềm cần phải thực thi và để thực hiện nó cần một môi trường để chạy. Runtime Enviroment tải các tệp lớp và đảm bảo có quyền truy cập vào bộ nhớ và các tài nguyên hệ thống khác để chạy chúng. Trước đây, hầu hết các phần mềm đều sử dụng hệ điều hành (HĐH) làm Runtime Enviroment. Chương trình chạy bên trong bất kỳ máy tính nào được bật, nhưng dựa vào cài đặt hệ điều hành để truy cập tài nguyên. Tài nguyên trong trường hợp này sẽ là những thứ như bộ nhớ và tệp chương trình và dependencies. Java Runtime Enviroment đã thay đổi tất cả, ít nhất là đối với các chương trình Java.
JRE chứa các thư viện và phần mềm mà các chương trình Java của bạn cần chạy. Ví dụ, trình tải lớp Java là một phần của Java Runtime Environment. Phần mềm quan trọng này tải mã Java được biên dịch vào bộ nhớ và kết nối mã với các thư viện lớp Java thích hợp.
What is JVM?
JVM is an engine that provides a runtime environment to drive the Java Code or applications. It converts Java bytecode into machine language. JVM is a part of Java Run Environment (JRE). It cannot be separately downloaded and installed. To install JVM, you need to install JRE. The full form of JVM is Java Virtual Machine.
In many other programming languages, the compiler produces machine code for a specific system. However, Java compiler produces code for a virtual machine which is called as JVM.
JDK & JRE distributions
Java is maintained by Oracle, who offer their own approved JDK. But many other organisations offer JDK builds.
Here’s a summary of some of the most popular, specifically for the current long term support (LTS) Java 17.
JDK Build | Organisation | JRE available | Free commercial use |
Oracle JDK | Oracle | ✅ (NFTC license) | |
Oracle OpenJDK | Oracle | ✅ (GNU license) | |
Amazon Corretto | Amazon | ✅ (for Amazon Linux 2) | ✅ (GNU license) |
Eclipse Temurin by Adoptium | Eclipse | ✅ (Eclipse license) |
Interestingly, even though Oracle used to offer a JRE for earlier Java releases, that’s no longer the case. How come?
jlink signals the end of pre-built JREs
Well, JDK 9 adds a new tool called
jlink
to go alongside the new Platform Module System.
jlink
lets you build your own minimal JRE with only the required libraries, saving on storage and offering improved performance over the pre-built JREs that came before.
Since it’s possible to build your own JRE, Oracle no longer saw a need to offer one. Other organisations like Amazon and Eclipse realised that some developers do still use pre-built JREs, so continue to offer it.
Java Runtime Environment (JRE)
JRE is the software environment where the compiled Java byte codes executes. JRE is the implementation of JVM it includes the code required for running the programs and native code. It contains the implementation of Java interpreter, garbage collector, class loader, java class libraries and related files. You can download the JRE separately or as a bundle along with JDK from Oracle’s website.
Features of JRE
Here are theimportant features of JRE:
- Java Runtime Environment is a set of tools using which the JVM actually runs.
- JRE contains deployment technology, including Java Web Start and Java Plug-in.
- Developers can easily run the source code in JRE, but he/she cannot write and compile the Java program.
- It includes integration libraries like Java Database Connectivity (JDBC), Remote Method Invocation (RMI), Java Naming and Directory Interface (JNDI), and more.
- JRE has JVM and Java HotSpot virtual machine client.
How JDK Functions?
Here are the important components of JDK:
- JDK and JRE: The JDK enables programmers to create core Java programs that can be run by the JRE, which included JVM and class libraries.
- Class Libraries: It is a group of dynamically loadable libraries that Java program can call at run time.
- Compilers: It is a Java program that accepts text file of developers and compiles into Java class file. It is the common form of output given by compiler, which contains Java byte code. In Java, the primary compiler is Javac.
- Debuggers: Debugger is a Java program that lets developers test and debug Java programs.
- JavaDoc: JavaDoc is documentation made by Sun Microsystems for the Java. JavaDoc can be used generating API documentation in HTML file from the source program
Conslusion
You now know the main differences between the Java Development Kit (JDK) and the Java Runtime Environment (JRE).
-
JDK includes tools for development such as compiler
-
JRE is for running Java applications only
-
JDK includes JRE for convenience
You also saw practically how to compile code with the JDK and run it with the JRE.
Have a question on this topic? I’m always looking for ways to improve this article, so leave a comment below and I’ll get back to you ASAP.
JDK vs JRE vs JVM in Java – Difference Between Them
Why use JDK?
Here are the important reasons of using JDK:
- JDK contains tools required to write Java programs, and JRE to execute them.
- It includes a compiler, Java application launcher, Appletviewer, etc.
- Compiler converts code written in Java into byte code.
- Java application launcher opens a JRE, loads the necessary class, and executes its main method.
Java Virtual Machine (JVM)
JVM is an abstract computing machine used to implement Java language. JVM is the key component in the Java eco system. Java’s important property is platform independence and to achieve that the role of JVM is critical. The JVM sits on top of the hardware and is used to execute the Java programs. Input for the JVM is Java byte code and it interprets the instructions in the byte code thus executing the programs.
Why JVM?
Here are the important reasons of using JVM:
- JVM provides a platform-independent way of executing Java source code.
- It has numerous libraries, tools, and frameworks.
- Once you run Java program, you can run on any platform and save lots of time.
- JVM comes with JIT(Just-in-Time) compiler that converts Java source code into low-level machine language. Hence, it runs more faster as a regular application.
JRE (Java Runtime Environment)
While the focus of the JDK is on developing Java applications, the JRE (Java Runtime Environment) is all about running them. It’s a library which you install on any machine you need to run Java programs.
What sort of library? Here’s what we see if we list of the contents of the JRE.
$ ls -l /C/Java/jdk-17.0.3+7-jre/ total 76 drwxr-xr-x 1 Tom 197121 0 Apr 20 00:13 bin/ drwxr-xr-x 1 Tom 197121 0 Apr 19 23:04 conf/ drwxr-xr-x 1 Tom 197121 0 Apr 19 23:04 legal/ drwxr-xr-x 1 Tom 197121 0 Apr 19 23:04 lib/ -rw-r--r-- 1 Tom 197121 2439 Apr 19 23:10 NOTICE -rw-r--r-- 1 Tom 197121 1592 Apr 19 23:10 release
This is the minimum set of files needed to run any Java application. The most important is
java.exe
inside the bin directory. Use the
java
command to execute Java application
.class
files.
When you do this, a JVM starts up to execute statements contained within
.class
files. So you can think of JRE as containing the JVM, but more accurately the JRE has the libraries to start the JVM.
What else is in the JRE?
Also in the JRE are many libraries that Java applications may rely on at runtime. You’ll probably be familiar with some of them, for example:
-
java.util.*
packages (e.g.
java.util.Map
) -
java.lang.*
packages (e.g.
java.lang.Integer
)
But note that the JRE doesn’t include any of the development tools like
javac
and
jar
. That’s what the JDK is for. The JRE is only for running Java applications.
Let’s run something using the JRE
Let’s put the JRE to the test and get it running something!
Remember that we compiled
HelloWorld.java
into
HelloWorld.class
earlier using the JDK? Running it in the JRE is as simple as passing the class name to the
java
command.
$ /C/Java/jdk-17.0.3+7-jre/bin/java HelloWorld Hello world!
Awesome! We got the expected output. Every Java application starts here.
But when we run
java
there’s quite a lot happening in the background just to print a simple string:
-
a ClassLoader loads
.class
files into the JVM, so it doesn’t need to know about the filesystem -
the JVM executes classes and manages memory areas like the heap and stack
-
eventually the JVM interacts with native operating system libraries to execute commands
So we’ve compiled an application using the JDK and run it with the JRE. Are we all done here?
Hang on! There’s more to this story, since the JDK actually contains a JRE itself…
What is JRE?
JRE stands for Java Runtime Environment. It is a runtime environment that is used for running the java applications in our system. The JRE contains JVM (Java Virtual Machine) along with a set of libraries and utilities that are required in order to run java applications. When we try to execute a java application, a runtime environment is provided by the JRE that contains all the necessary components that are required by the application to execute.
Features of JRE:
- JRE is a collection of tools that helps in the execution of the JVM. It also provides a few deployment tools like Java Plug-in and Java Web Start.
- A user can run java code efficiently with only JRE. Unfortunately, JRE does not allow writing java programs.
- JRE also includes some integration libraries such as JDBC (Java Database Connectivity), JNDI (Java Naming and Directory Interface), RMI (Remote Method Invocation), and others.
- In addition to JVM, it also contains a virtual machine client for Java HotSpot.
Quản lý bộ nhớ trong java 8
Cho đến Java 8, metaspace được biết đến như là permgen. Bên cạnh việc là một cái tên hay hơn nhiều, metaspace là một thay đổi quan trọng đối với cách các nhà phát triển tương tác với không gian bộ nhớ của Java. Trước đây, bạn sẽ sử dụng lệnh * java -XX: MaxPermSize* để theo dõi kích thước của không gian permgen. Từ Java 8 trở đi, Java sẽ tự động tăng kích thước của metaspace để đáp ứng nhu cầu meta của chương trình của bạn. Java 8 cũng giới thiệu một cờ mới, MaxMetaspaceSize, có thể được sử dụng để giới hạn kích thước metaspace.
Các tùy chọn bộ nhớ khác, heap và stack, vẫn giữ nguyên trong Java 8.
Quản lí bộ nhớ trong JVM
Tương tác phổ biến nhất với JVM đang chạy là kiểm tra mức sử dụng bộ nhớ trong heap và stack. Điều chỉnh phổ biến nhất là điều chỉnh các cài đặt bộ nhớ của JVM.
Thu gom rác(Garbage collection)
Trước Java, tất cả bộ nhớ chương trình được quản lý bởi lập trình viên. Trong Java, bộ nhớ chương trình được quản lý bởi JVM. JVM quản lý bộ nhớ thông qua một quá trình gọi là bộ sưu tập rác(garbage collection), liên tục xác định và loại bỏ bộ nhớ không sử dụng trong các chương trình Java. Việc thu gom rác xảy ra bên trong một JVM đang chạy.
Bộ nhớ Java và JRE
Bộ nhớ Java bao gồm ba thành phần: heap, stack và metaspace (trước đây được gọi là permgen).
- Metaspace là nơi Java giữ thông tin không thay đổi của chương trình như các định nghĩa lớp.
- Không gian heap (Heap space) là nơi Java giữ nội dung biến(variable content).
- Không gian ngăn xếp (Stack space) là nơi Java lưu trữ thực thi hàm(function execution) và tham chiếu biến(variable references).
What is JDK?
JDK stands for Java Development Kit. It is a complete software environment for building applications using Java language. It contains a collection of tools and utilities which are very essential for a developer for writing, compiling, and debugging. The JDK is platform-dependent and because of this reason, it has different OS platform versions for Windows, Linux, Mac, and so on.
The JDK contains the Java Runtime Environment (JRE), which provides the Java Virtual Machine (JVM) for executing Java code. The JDK also contains the Java compiler, which converts our Java source code into Java bytecode that can be executed on any machine that has a compatible JVM in it. The JDK also offers a variety of tools for debugging, testing, and monitoring our Java applications.
Below listed are the features of JDK:
- JDK provides an environment for writing and running Java source code.
- JDK provides all the functionalities of JRE and JVM.
- JDK enables developers in handling exceptions smoothly by integrating many extensions together into a single catch block.
- It also provides a debugger, compiler, and other development tools.
Difference Between JDK, JRE and JVM
Here are the major differences between JDK vs. JRE vs. JVM:
JDK | JRE | JVM |
The full form of JDK is Java Development Kit. | The full form of JRE is Java Runtime Environment. | The full form of JVM is Java Virtual Machine. |
JDK is a software development kit to develop applications in Java. | It is a software bundle which provides Java class libraries with necessary components to run Java code. | JVM executes Java byte code and provides an environment for executing it. |
JDK is platform dependent. | JRE is also platform dependent. | JVM is highly platform dependent. |
It contains tools for developing, debugging, and monitoring java code. | It contains class libraries and other supporting files that JVM requires to execute the program. | Software development tools are not included in JVM. |
It is the superset of JRE | It is the subset of JDK. | JVM is a subset of JRE. |
The JDK enables developers to create Java programs that can be executed and run by the JRE and JVM. | The JRE is the part of Java that creates the JVM. | It is the Java platform component that executes source code. |
JDK comes with the installer. | JRE only contain environment to execute source code. | JVM bundled in both software JDK and JRE. |
Trong bài này, chúng ta sẽ tìm hiểu về JVM, JRE, JDK. Nó bao gồm những thành phần nào và nhiệm vụ của nó là gì?
JVM (Java Virtual Machine) là tạo ra môi trường máy ảo để thực thi mã java bytecode.
- Máy ảo Java là phần mềm giả lập máy tính, nó tập hợp các lệnh logic để xác định hoạt động của máy.
- Có thể xem nó như là một hệ điều hành thu nhỏ.
- JVM chuyển mã byte code thành machine code tùy theo môi trường tương ứng (gọi là khả năng khả chuyển)
- JVM cung cấp môi trường thực thi cho chương trình Java (gọi đó là khả năng độc lập với nền).
JVM có sẵn trong nhiều phần cứng và nền tảng phần mềm.
JVM gồm 4 nhiệm vụ chính: Load code, Verifies code, Executes code, Provides runtime enviroment.
JRE viết tắt Java Runtime Enviromement. Nó bao gồm các thư viện và các file mà JVM sử dụng lúc thực thi.
JDK viết tắt của Java Development Kit. Nó gồm JRE + công cụ phát triển.
Bộ công cụ JDK gồm các chương trình thực thi đáng chú ý sau:
- javac: Chương trình biên dịch các chương trình nguồn viết bằng ngôn ngữ java ra các tập tin thực thi được trên máy ảo Java.
- java: Một chương trình để dịch mã mà bạn viết thành mã bytecode, khi ứng dụng Java chạy nó dịch mã bytecode thành mã máy tính và thực thi, điều đó có nghĩa là bytecode chỉ là một mã trung gian.Đây là chương trình làm máy ảo của Java, thông dịch mã Bytecode của các chương trình kiểu application thành mã thực thi của máy thực.
- Archive (jar): Là một chương trình nén các file thành một file duy nhất có đuôi jar. Thường dùng để đóng gói các file class.
- Javadoc: Là một công cụ tạo ra tài liệu hướng dẫn sử dụng API.
- appletviewer: Bộ thông dịch, thực thi các chương trình kiểu applet.
- javadoc: Tạo tài liệu về chú thích chương trình nguồn một cách tự động.
- jdb: Trình gở rối.
- rmic: Tạo Stub cho ứng dụng kiểu RMI.
- rmiregistry: Phục vụ danh bạ (Name Server) trong hệ thống RMI
Java Development Kit (JDK) is a software development environment used for developing Java applications and applets. It includes the Java Runtime Environment (JRE), an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), and other tools needed in Java development.
Now we need an environment to make a run of our program. Henceforth, JRE stands for “Java Runtime Environment” and may also be written as “Java RTE.” The Java Runtime Environment provides the minimum requirements for executing a Java application; it consists of the Java Virtual Machine (JVM), core classes, and supporting files.
Now let us discuss JVM, which stands out for java virtual machines. It is as follows:
- A specification where the working of Java Virtual Machine is specified. But implementation provider is independent to choose the algorithm. Its implementation has been provided by Sun and other companies.
- An implementation is a computer program that meets the requirements of the JVM specification.
- Runtime Instance Whenever you write a java command on the command prompt to run the java class, an instance of JVM is created.
Before proceeding to the differences between JDK, JRE, and JVM, let us discuss them in brief first and interrelate them with the image below proposed.
Don’t get confused as we are going to discuss all of them one by one.
1. JDK (Java Development Kit) is a Kit that provides the environment to develop and execute(run) the Java program. JDK is a kit(or package) that includes two things
- Development Tools(to provide an environment to develop your java programs)
- JRE (to execute your java program).
2. JRE (Java Runtime Environment) is an installation package that provides an environment to only run(not develop) the java program(or application)onto your machine. JRE is only used by those who only want to run Java programs that are end-users of your system.
3. JVM (Java Virtual Machine) is a very important part of both JDK and JRE because it is contained or inbuilt in both. Whatever Java program you run using JRE or JDK goes into JVM and JVM is responsible for executing the java program line by line, hence it is also known as an interpreter.
Now let us discuss the components of JRE in order to understand its importance of it and perceive how it actually works. For this let us discuss components.
The components of JRE are as follows:
- Deployment technologies, including deployment, Java Web Start, and Java Plug-in.
- User interface toolkits, including Abstract Window Toolkit (AWT), Swing, Java 2D, Accessibility, Image I/O, Print Service, Sound, drag, and drop (DnD), and input methods.
- Integration libraries, including Interface Definition Language (IDL), Java Database Connectivity (JDBC), Java Naming and Directory Interface (JNDI), Remote Method Invocation (RMI), Remote Method Invocation Over Internet Inter-Orb Protocol (RMI-IIOP), and scripting.
- Other base libraries, including international support, input/output (I/O), extension mechanism, Beans, Java Management Extensions (JMX), Java Native Interface (JNI), Math, Networking, Override Mechanism, Security, Serialization, and Java for XML Processing (XML JAXP).
- Lang and util base libraries, including lang and util, management, versioning, zip, instrument, reflection, Collections, Concurrency Utilities, Java Archive (JAR), Logging, Preferences API, Ref Objects, and Regular Expressions.
- Java Virtual Machine (JVM), including Java HotSpot Client and Server Virtual Machines.
After having an adequate understanding of the components, now let us discuss the working of JDK. In order to understand how JDK works, let us consider an illustration below as follows:
Illustration:
Consider a java source file saved as ‘Example.java’. The file is compiled into a set of Byte Code that is stored in a “.class” file. Here it will be “Example.class“.
Note: From above, media operation computing during the compile time can be interpreted.The following actions occur at runtime as listed below:
- Class Loader
- Byte Code Verifier
- Interpreter
- Execute the Byte Code
- Make appropriate calls to the underlying hardware
Now let us discuss in brief how JVM works out. It is as follows:
JVM becomes an instance of JRE at the runtime of a Java program. It is widely known as a runtime interpreter.JVM largely helps in the abstraction of inner implementation from the programmers who make use of libraries for their programs from JDK.
It is mainly responsible for three activities.
- Loading
- Linking
- Initialization
Similarly, now let us discuss the working of JRE which is as follows:
- JVM(Java Virtual Machine) acts as a run-time engine to run Java applications. JVM is the one that actually calls the main method present in a java code. JVM is a part of JRE(Java Runtime Environment).
- Java applications are called WORA (Write Once Run Anywhere). This means a programmer can develop Java code on one system and can expect it to run on any other Java-enabled system without any adjustments. This is all possible because of JVM.
- When we compile a .java file, .class files(contains byte-code) with the same class names present in .java file are generated by the Java compiler. This .class file goes into various steps when we run it. These steps together describe the whole JVM.
Feeling lost in the vast world of Backend Development? It’s time for a change! Join our Java Backend Development – Live Course and embark on an exciting journey to master backend development efficiently and on schedule. What We Offer:
- Comprehensive Course
- Expert Guidance for Efficient Learning
- Hands-on Experience with Real-world Projects
- Proven Track Record with 100,000+ Successful Geeks
Last Updated :
03 Oct, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment…
By Pankaj
While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.
The difference between JDK, JRE, and JVM is one of the popular interview questions. You might also be asked to explain JDK vs JRE vs JVM.
JDK, JRE, and JVM are core concepts of Java programming language. We don’t use these concepts in programming. But, as a Java developer, we should know about them.
Java Development Kit aka JDK is the core component of Java Environment and provides all the tools, executables, and binaries required to compile, debug, and execute a Java Program. JDK is a platform-specific software and that’s why we have separate installers for Windows, Mac, and Unix systems. We can say that JDK is the superset of JRE since it contains JRE with Java compiler, debugger, and core classes.
JVM is the heart of Java programming language. When we execute a Java program, JVM is responsible for converting the byte code to the machine-specific code. JVM is also platform-dependent and provides core java functions such as memory management, garbage collection, security, etc. JVM is customizable and we can use java options to customize it. For example, allocating minimum and maximum memory to JVM. JVM is called virtual because it provides an interface that does not depend on the underlying operating system and machine hardware. This independence from hardware and the operating system makes java program write-once-run-anywhere.
JRE is the implementation of JVM. It provides a platform to execute java programs. JRE consists of JVM, Java binaries, and other classes to execute any program successfully. JRE doesn’t contain any development tools such as Java compiler, debugger, JShell, etc. If you just want to execute a java program, you can install only JRE. You don’t need JDK because there is no development or compilation of java source code is required. Now that we have a basic understanding of JDK, JVM, and JRE, let’s look into the difference between them.
Let’s look at some of the important differences between JDK, JRE, and JVM.
Sometimes you will find JIT alongside JVM, JDK, and JRE in textbooks. JIT is part of the JVM that optimizes the process of converting byte code to machine-specific language. It compiles similar byte codes at the same time and reduces the overall time taken for the compilation of byte code to machine-specific language.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
Below text from this article – JVM is called virtual because it provides an interface that does not depend on the underlying operating system and machine hardware. This independence from hardware and the operating system is what makes java program write-once-run-anywhere. Does JVM provided interface not depend on underlying platform. If that interface (i.e. loding, linking, JIT, interpreter etc) is same for all platforms then why JVMs are different for each platform. I feel this interface which takes byte code as input and gives you end result is platform dependent which makes Java platform independent. May be you can correct my understanding.
– Love Gupta
Thanks a lot!
– Saangram
Please update the version of Java.
– srinivas narla
very well explained,
– Vitthal Kasbe
JVM is also platform dependent under JVM , i hope this is a TYPO.
– Sailendra
I wish to know step by step execution and impacts , functionalties for jdk, jvm (including memory areas )m jre ? I mean i wish to know end-to-end flow when a java program gets executed (specially through various section inside JVM – among those i also wish to know impacts on memory areas (heap,stack, native area ), class loaders e.t.c.
– Bibhu Prasad Tripathy
very good.
– Leandro
Hi Pankaj, Thanks for such useful tutorials. You are doing great. Keep it up. I have some doubt about JIT. You said that it optimizes byte code to machine specific language compilation by compiling similar byte codes at same time. My question is that while converting byte code into machine specific code do all the byte code passes through JIT. Because i have heared that only interpretor also have its role in converting byte code into machine specific code. Or only similar byte codes are passes through JIT and rest all passes through interpreter. It would be very useful if you can elaborate it with some example.
– debu
This is to just let you know that you could update regarding ‘Current JDK Version’ information.
– gansai
I’m confused when I go to Oracles site to download the JDK and they ask if you want JDK for Java EE or JDK for Java SE. What if I want to ability to develop both. Do I really have to install 2 separate JDKs?
– Mike
Click below to sign up and get $200 of credit to try our products over 60 days!
Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hiểu rõ sự khác nhau giữa JDK, JRE và JVM là điều khá quan trọng trong Java.
Nội dung chính
JDK (Java Development Kit)
The JDK (Java Development Kit) is a library which you download to your computer to help you develop Java applications.
What kind of library? Whether you use an installer, package manager, or zip file to setup the JDK, you end up with a directory structure like this.
$ ls -l /C/Java/jdk-17.0.2 total 128 drwxr-xr-x 1 Tom 197121 0 Dec 7 21:56 bin/ drwxr-xr-x 1 Tom 197121 0 Dec 7 21:56 conf/ drwxr-xr-x 1 Tom 197121 0 Dec 7 21:56 include/ drwxr-xr-x 1 Tom 197121 0 Dec 7 21:56 jmods/ drwxr-xr-x 1 Tom 197121 0 Dec 7 21:56 legal/ drwxr-xr-x 1 Tom 197121 0 Dec 7 21:56 lib/ -rw-r--r-- 1 Tom 197121 1241 Dec 7 21:56 release
What the heck is all this stuff? It’s a suite of juicy tools to help you do an awesome job as a Java developer.
The JDK bin directory
For example, in the bin directory are these programs:
-
javac: compiles
.java
source files into binary
.class
files in bytecode format -
jar: creates a
.jar
file archive from all your
.class
files, for easy distribution -
javadoc: generates HTML documentation from your Java source files
There are in total 35 tools in the JDK bin directory, including JConsole, used to monitor Java applications. Have a look yourself and try running them!
Let’s compile something using the JDK
One of the most important tools in the JDK is
javac
. Without it you wouldn’t be able to compile your source code to later run using the JRE (more on that later).
Let’s try compiling this simple
HelloWorld.java
class using
javac
.
class HelloWorld { public static void main(String\[\] args) { System.out.println("Hello world!"); } }
We just pass the file name to
javac
and the compiler spits out a
.class
file.
$ ls HelloWorld.java $ /C/Java/jdk-17.0.3+7/bin/javac HelloWorld.java $ ls HelloWorld.class HelloWorld.java
And what’s so great about a
.class
file?
Well, it’s important to know that the JVM (Java Virtual Machine) receives instructions through bytecode (
.class
files) and NOT source files (
.java
) files. Bytecode has been optimised and compressed specifically for the JVM to run as fast as possible.
We’ll learn more about the JVM later when we use it to run our HelloWorld application.
JDK key facts
-
it’s a set of tools for developing Java applications
-
includes the javac compiler command to generate Java bytecode from source code
-
has many other tools within bin directory (jar, javadoc etc.)
-
install and use it on your development machine
-
also use on Continuous Integration (CI) servers to build Java applications
Tìm hiểu JVM
JVM (viết tắt của Java Virtual Machine) là một thiết bị trừu tượng (ảo) có thể giúp máy tính chạy các chương trình Java. Nó cung cấp môi trường runtime mà trong đó Java Bytecode có thể được thực thi.
JVM là có sẵn cho nhiều nền tảng (Windows, Linux…). JVM, JRE và JDK là phụ thuộc nền tảng, bởi vì cấu hình của mỗi OS (hệ điều hành) là khác nhau. Nhưng, Java là độc lập nền tảng.
Các nhiệm vụ chính của JVM
- Tải code
- Kiểm tra code
- Thực thi code
- Cung cấp môi trường runtime
Cấu trúc của JVM
Trong đó:
- Classloader: Là một hệ thống con của JVM được sử dụng để tải class file.
- Class (method) Area: Lưu trữ cấu trúc mỗi lớp, chẳng hạn như hằng, trường, dữ liệu phương thức, code của phương thức, …
- Heap: Nó là khu vực dữ liệu runtime mà trong đó đối tượng được cấp phát.
-
Stack: Stack trong Java lưu giữ các Frame. Nó giữ các biến cục bộ và các kết quả cục bộ, và thực hiện một phần nhiệm vụ trong phần triệu hồi và trả về phương thức. Mỗi Thread có một Stack riêng, được tạo tại cùng thời điểm với Thread.
Một Frame mới được tạo mỗi khi một phương thức được triệu hồi và bị hủy khi lời triệu hồi phương thức là kết thúc. - Program Counter Register: Nó chứa địa chỉ của chỉ lệnh JVM hiện tại đang được thực thi.
- Native Method Stack: Bao gồm tất cả các phương thức tự nhiện được sử dụng trong ứng dụng.
-
Execution Engine: Phần này bao gồm:
Một bộ xử lý ảo Virtual ProcessorMột trình thông dịch Interpreter. Đọc Bytecode Stream sau đó thực thi các chỉ thị. - Just-In-Time (JIT) Compiler: được sử dụng để cải thiện hiệu suất. JIT biên dịch các phần của Bytecode mà có cùng tính năng tại cùng một thời điểm, và vì thế giảm lượng thời gian cần thiết để biên dịch. Ở đây khái niệm Compiler là một bộ biên dịch tập chỉ thị của JVM thành tập chỉ thị của một CPU cụ thể.
JDK & JRE similarities
Whaaat! There’s really a JRE inside the JDK? 🤔
Yes, there are quite a few similarities between the JDK and JRE, so let’s take a closer look.
JDK contains a JRE
When you download and install the Java Development Kit (JDK) not only do you have everything needed to compile Java applications, but also to run them too! Or in other words, the JDK contains the Java Runtime Environment (JRE).
If my name were Venn and not Tom, I’d illustrate the idea like this.
The JDK includes the JRE to make development as simple as possible. We can compile and run applications using one JDK installation, without any other downloads.
Let’s try compiling and running HelloWorld using only the JDK.
$ /C/Java/jdk-17.0.3+7/bin/javac HelloWorld.java $ /C/Java/jdk-17.0.3+7/bin/java HelloWorld Hello world!
Why use the JRE?
If the JDK already includes the JRE, wouldn’t you always use the JDK to compile and run applications?
Yes, it’s perfectly valid to install a JDK onto a production server and use it to run Java applications. But there are some special use cases to consider.
-
size: the JRE is less than half the size of the JDK. Remember all those extra JDK development tools? If your target environment is a device with limited storage, install a JRE instead.
-
security: given all the extra tooling packaged in the JDK, it’s more secure and clean not to make it available in production by instead using the JRE
To see for yourself, let’s compare the size of the JDK and JRE.
$ du -hs /C/Java/jdk-17.0.3+7 301M /C/Java/jdk-17.0.3+7 $ du -hs /C/Java/jdk-17.0.3+7-jre 124M /C/Java/jdk-17.0.3+7-jre
Using the
diff
command you can also check the differences between the JDK and JRE. From my investigation I see that the JDK contains 52 files that aren’t in the JRE! None of those are required for running Java applications.
Platform dependent
Both the JDK and JRE are platform dependent. That means you can only use a version that’s been built for the specific type of machine you’re using.
The JDK is available for:
-
Windows
-
MacOS
-
Linux
The cool thing about Java is that the bytecode generated by the JDK’s compiler can be run anywhere that a JRE is available. This is the write once, run anywhere ethos of Java.
For example, you can compile Java source code on a Windows machine and run it on Linux. No problem.
What is JVM?
JVM stands for Java Virtual Machine, and it is a software component that allows your computer to run Java programs. When we write a Java program, it is compiled into bytecode. This bytecode can not execute on its own and requires JVM to run it.
The JVM has the responsibility of executing the bytecode and converting it into machine code that can be understood by the computer. The JVM also manages memory usage and performs garbage collection, which is the process of deallocating memory that is no longer needed by the program.
Listed below are some features of JVM
- JVM converts byte code into machine code which is understood by the computer.
- JVM provides fundamental Java functionalities such as management of memory, garbage collection, and so on.
- JVM uses libraries and files of JRE to run the java program.
- JVM is an essential component of JRE.
- It is capable of executing the java program line by line. Hence, it is also referred to as an interpreter.
- Primary functions of JVM includes program loading, linking, initialization, and compilation.
Features of JDK
Here are the important features of JDK:
- It enables you to handle multiple extensions in a single catch block.
- JDK includes all features that JRE has.
- It contains development tools such as a compiler, debugger, etc.
- JDK provides the environment to develop and execute Java source code.
- It can be installed on Windows, Unix, and Mac operating systems.
- Diamond operator can be used in specifying a generic type interface instead of writing the exact one.
How JVM Functions?
Here are the important components of JVM:
1) Class Loader
The class loader is a subsystem used for loading class files. It performs three major functions viz. Loading, Linking, and Initialization.
2) Method Area
JVM Method Area stores structure of class like metadata, the code for Java methods, and the constant runtime pool.
3) Heap
All the Objects, arrays, and instance variables are stored in a heap. This memory is shared across multiple threads.
4) JVM language Stacks
Java language Stacks store local variables, and its partial results. Each and every thread has its own JVM language stack, created concurrently as the thread is created. A new frame is created when method is invoked, and it is removed when method invocation process is complete.
5) PC Registers
PC registers store the address of the Java virtual machine instruction, which is currently executing. In Java, each thread has its separate PC register.
6) Native Method Stacks
Native method stacks hold the instruction of native code depends on the native library. It allocates memory on native heaps or uses any type of stack.
7) Execution Engine
It is a type of software that is used to test software, hardware, or complete systems. The test execution engine never carries any information about the tested product.
8) Native Method interface
The Native Method Interface is a programming framework. It allows Java code, which is running in a JVM to call by libraries and native applications.
9) Native Method Libraries
Native Libraries is a collection of the Native Libraries (C, C++), which are needed by the Execution Engine.
Difference Between JDK, JRE and JVM
After reading the above introduction of all three components, now we will go through the table below to see the head-to-head difference between JDK JRE and JVM.
JDK | JRE | JVM |
JDK stands for Java Development Kit. | JRE stands for Java Runtime Environment. | JVM stands for Java Virtual Machine. |
The Java Development Kit (JDK) is a software development kit that lets you build Java applications. | The Java Runtime Environment (JRE) is a software package that includes the Java Virtual Machine (JVM), class libraries, and other components required to run Java applications. | The Java Virtual Machine (JVM) is an abstract machine that provides an environment for Java ByteCode execution. |
JDK includes tools for creating, monitoring, and debugging Java code. | JRE includes class libraries and other supporting files needed by JVM to run Java code. | JVM has no software development tools. |
It is platform-dependent | It is also platform-dependent like JDK | It is platform-independent |
The JDK mainly assists in code execution. Its primary purpose is development. | JRE is primarily tasked with creating an environment for code execution. | All implementations are specified by JVM. It is in charge of providing all of these implementations to the JRE. |
JDK = Development Tools + JRE | JRE = Class libraries + JVM | JVM = provides a runtime environment. |
ConclusionIn essence, comprehending the disparity between JDK, JRE, and JVM is crucial for any Java developer. The JDK encompasses the complete set of tools needed for Java development, including the JRE, whereas the JRE is an execution environment for running Java applications. On the other hand, the JVM is the runtime instance that executes Java bytecode. Together, these components form a cohesive ecosystem that facilitates Java programming, ensuring seamless development, deployment, and execution of Java applications across various platforms.
Difference Between JDK, JRE, and JVM
Parameter | JDK | JRE | JVM |
Full-Form | The JDK is an abbreviation for Java Development Kit. | The JRE is an abbreviation for Java Runtime Environment. | The JVM is an abbreviation for Java Virtual Machine. |
Definition | The JDK (Java Development Kit) is a software development kit that develops applications in Java. Along with JRE, the JDK also consists of various development tools (Java Debugger, JavaDoc, compilers, etc.) | The Java Runtime Environment (JRE) is an implementation of JVM. It is a type of software package that provides class libraries of Java, JVM, and various other components for running the applications written in Java programming. | The Java Virtual Machine (JVM) is a platform-independent abstract machine that has three notions in the form of specifications. This document describes the requirement of JVM implementation. |
Functionality | The JDK primarily assists in executing codes. It primarily functions in development. | JRE has a major responsibility for creating an environment for the execution of code. | JVM specifies all of the implementations. It is responsible for providing all of these implementations to the JRE. |
Platform Dependency | The JDK is platform-dependent. It means that for every different platform, you require a different JDK. | JRE, just like JDK, is also platform-dependent. It means that for every different platform, you require a different JRE. | The JVM is platform-independent. It means that you won’t require a different JVM for every different platform. |
Tools | Since JDK is primarily responsible for the development, it consists of various tools for debugging, monitoring, and developing java applications. | JRE, on the other hand, does not consist of any tool- like a debugger, compiler, etc. It rather contains various supporting files for JVM, and the class libraries that help JVM in running the program. | JVM does not consist of any tools for software development. |
Implementation | JDK = Development Tools + JRE (Java Runtime Environment) | JRE = Libraries for running the application + JVM (Java Virtual Machine) | JVM = Only the runtime environment that helps in executing the Java bytecode. |
Why Use It? |
Why use JDK?
Some crucial reasons to use JDK are: |
Why use JRE?
Some crucial reasons to use JRE are: |
Why use JVM?
Some crucial reasons to use JVM are: |
Features | Features of JDK | Features of JRE |
Features of JVM
Here are a few crucial features of JVM: |
Keep learning and stay tuned to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2023, GATE Admit Card, GATE Application Form, GATE Syllabus, GATE Cut off, GATE Previous Year Question Paper, and more.
The article goes through explaining Java Virtual Machine (JVM), Java Runtime Environment (JRE), and Java Development Kit (JDK) in detail. Moreover, it covers the differences between JVM, JRE, and JDK.
Ja
va is a popular programming language for developing various applications, from desktop software to web applications and mobile apps. When working with Java, you may come across the terms JDK, JRE, and JVM, all of which are important components of the Java ecosystem.
JDK, JRE, and JVM are three distinct components used to run Java applications, but they each serve a different purpose. Understanding the differences between these components is important for Java developers and anyone else who works with Java applications. This blog post will explore the differences between JDK, JRE, and JVM and explain why each component is important in Java development.
The article goes through explaining Java Virtual Machine (JVM), Java Runtime Environment (JRE), and Java Development Kit (JDK) in detail. Moreover, it covers the differences between JVM, JRE, and JDK.
Ja
va is a popular programming language for developing various applications, from desktop software to web applications and mobile apps. When working with Java, you may come across the terms JDK, JRE, and JVM, all of which are important components of the Java ecosystem.
JDK, JRE, and JVM are three distinct components used to run Java applications, but they each serve a different purpose. Understanding the differences between these components is important for Java developers and anyone else who works with Java applications. This blog post will explore the differences between JDK, JRE, and JVM and explain why each component is important in Java development.
What is JVM?
JVM (Java Virtual Machine) is an abstract machine that enables your computer to run a Java program.
When you run the Java program, Java compiler first compiles your Java code to bytecode. Then, the JVM translates bytecode into native machine code (set of instructions that a computer’s CPU executes directly).
Java is a platform-independent language. It’s because when you write Java code, it’s ultimately written for JVM but not your physical machine (computer). Since JVM executes the Java bytecode which is platform-independent, Java is platform-independent.
If you are interested in learning about JVM Architecture, visit The JVM Architecture Explained.
Tải và thực thi class files trong JVM
Java class loader trong JVM
Mọi thứ trong java là một lớp(class), và tất cả các ứng dụng Java được xây dựng từ các lớp(classes). Một ứng dụng có thể bao gồm một lớp hoặc hàng ngàn lớp. Để chạy một ứng dụng Java, JVM phải tải các tệp .class đã biên dịch vào context, chẳng hạn như một máy chủ, nơi chúng có thể được truy cập. Một JVM phụ thuộc vào trình tải lớp của nó để thực hiện chức năng này.
Trình tải lớp Java là một phần của JVM tải các lớp vào bộ nhớ và làm cho chúng có sẵn để thực thi. Trình nạp lớp sử dụng các kỹ thuật như lazy-loading và caching để làm cho việc tải lớp hiệu quả nhất có thể.
Công cụ thực thi trong JVM(The execution engine in the JVM)
Khi trình tải lớp đã hoàn thành công việc tải các lớp, JVM bắt đầu thực thi mã trong mỗi lớp. Công cụ thực thi là thành phần JVM xử lý chức năng này. Công cụ thực thi là điều cần thiết cho JVM đang chạy. Mã thực thi liên quan đến việc quản lý truy cập vào tài nguyên hệ thống. Công cụ thực thi JVM nằm giữa chương trình đang chạy – với nhu cầu về tài nguyên tệp, mạng và bộ nhớ – và hệ điều hành, cung cấp các tài nguyên đó.
Cách công cụ thực thi quản lý tài nguyên hệ thống
Tài nguyên hệ thống có thể được chia thành hai loại lớn: bộ nhớ và mọi thứ khác.
Hãy nhớ lại rằng JVM chịu trách nhiệm xử lý bộ nhớ không sử dụng và bộ sưu tập rác(garbage collection) là cơ chế thực hiện việc xử lý đó. JVM cũng chịu trách nhiệm phân bổ và duy trì cấu trúc tham chiếu mà nhà phát triển được cấp. Ví dụ, công cụ thực thi của JVM chịu trách nhiệm lấy một cái gì đó giống như từ khóa new trong Java và biến nó thành một yêu cầu dành riêng cho hệ điều hành để cấp phát bộ nhớ.
Ngoài bộ nhớ, công cụ thực thi quản lý tài nguyên để truy cập hệ thống tệp và network I/O . Do JVM có thể tương tác trên các hệ điều hành, nên đây không phải là nhiệm vụ . Ngoài nhu cầu tài nguyên của từng ứng dụng, công cụ thực thi phải đáp ứng với từng môi trường HĐH.
JRE là gì? Giới thiệu Java Runtime Environment
JRE tạo JVM và đảm bảo các phụ thuộc có sẵn cho các chương trình Java của bạn.
Thực tế mà nói, runtime enviroment là một phần mềm được thiết kế để chạy các phần mềm khác. Là runtime enviroment cho Java, JRE chứa các thư viện lớp Java, trình tải lớp Java và Máy ảo Java. Trong hệ thống này:
- Trình tải lớp chịu trách nhiệm tải chính xác các lớp và kết nối chúng với các thư viện lớp Java cốt lõi.
- JVM chịu trách nhiệm đảm bảo các ứng dụng Java có tài nguyên mà chúng cần để chạy và hoạt động tốt trong thiết bị hoặc môi trường đám mây của bạn.
- JRE chủ yếu là một thùng chứa cho các thành phần khác và chịu trách nhiệm điều phối các hoạt động của chúng.
FAQs Related to the Difference Between JDK, JRE, JVM
Here are some frequently asked questions related to the differences between JDK, JRE, and JVM.
1. Is the JRE required to run Java applications?Yes, the JRE is required to run Java applications. When you run a Java application, the JRE provides a runtime environment that includes the JVM and a set of libraries and utilities required for executing the application.
2. Can I run Java applications without installing the JDK?Yes, you can run Java applications by installing the JRE (Java Runtime Environment). However, if you want to develop Java applications, you’ll need the JDK as it includes the JRE along with additional development tools.
3. How does the JVM facilitate platform independence in Java?The JVM interprets the Java bytecode generated by the Java compiler. It abstracts the underlying hardware and operating system, allowing Java programs to run on any device or platform that has a compatible JVM installed, thus ensuring platform independence.
4. Are there different versions of JDK, JRE, and JVM available?Yes, Oracle, as well as other organizations and communities, release different versions of JDK, JRE, and JVM. These versions often include updates, enhancements, and bug fixes to improve performance and security.
5. Is the JDK required on a system where only JRE is needed for running Java applications?If you only intend to run Java applications and not develop them, installing the JRE suffices. The JDK, which includes the JRE, is necessary only for development purposes.
For many Java developers, understanding how the JDK & JRE differ is a source of confusion. But knowing when to use each one is essential to develop and run Java applications effectively. In this article you’ll discover why the JDK & JRE exist, their differences & similarities, and practically how to use them.
Let’s begin with a quick overview of the JDK & JRE to get a taste of what they’re about.
Features of JVM
Here are the important features of JVM:
- It enables you to run applications in a cloud environment or in your device.
- Java Virtual Machine converts byte code to the machine-specific code.
- It provides basic java functions like memory management, security, garbage collection, and more.
- JVM runs the program by using libraries and files given by Java Runtime Environment.
- JDK and JRE both contain Java Virtual Machine.
- It can execute the java program line by line hence it is also called as interpreter.
- JVM is easily customizable for example, you can allocate minimum and maximum memory to it.
- It is independent from hardware and the operating system. So, you can write a java program once and run anywhere.
What is JDK?
JDK is an abbreviation for Java Development Kit. It is an environment of software development used for developing applets and Java applications. JDK has a physical existence, and it contains JRE + development tools. One can easily install more than one version of JDK on the same computer. The Java developers can make use of it on macOS, Windows, Linux, and Solaris. JDK assists them in coding and running the Java programs.
It is an implementation of any of the given Java Platforms that the Oracle Corporation released:
- Micro Edition
- Enterprise Edition
- Standard Edition
The JDK consists of a private JVM (Java Virtual Machine) along with a few other resources, java (a loader/interpreter), like javac (a compiler), Javadoc (a documentation generator), jar (an archiver), etc., for completing the process of Java application development.
Cấu hình không gian heap(Configuring heap space)
Không gian heap là phần động nhất của hệ thống bộ nhớ Java. Bạn có thể sử dụng các cờ -Xms và -Xmx để cho Java biết mức độ lớn để bắt đầu heap và mức độ lớn để cho phép nó trở thành. Hiểu cách điều chỉnh các cờ này cho các nhu cầu chương trình cụ thể là một khía cạnh quan trọng của quản lý bộ nhớ trong Java. Ý tưởng là làm cho heap đủ lớn để garbage collection hoạt động hiệu quả nhất. Đó là, bạn muốn cho phép đủ bộ nhớ để cho chương trình chạy, nhưng bạn không muốn nó lớn hơn mức cần thiết.
JVM, JDK, JRE: Có gì khác biệt giữa chúng?
Bài đăng này đã không được cập nhật trong 4 năm
Ba thành phần nền tảng Java không thể thiếu và cách chúng hoạt động cùng nhau trong các ứng dụng Java của bạn
Các nhà phát triển mới sử dụng Java thường tự hỏi có gì khác biệt Java Virtual Machine, Java Development Kit, Java Runtime Environment. Họ cũng tò mò về cách ba thành phần nền tảng Java này hoạt động cùng nhau trong các ứng dụng Java. Cuối cùng, các nhà phát triển cần biết họ sẽ tương tác với từng thành phần như thế nào.
Nói ngắn gọn:
- JVM là thành phần nền tảng Java thực thi các chương trình của bạn.
- JRE khởi tạo JVM và đảm bảo các phụ thuộc có sẵn cho các chương trình của bạn.
- JDK cho phép bạn tạo các chương trình Java có thể được thực thi và chạy bởi JVM và JRE.
Là nhà phát triển, bạn sẽ làm việc với JDK để viết các ứng dụng của mình và với JVM để gỡ lỗi và tối ưu hóa chúng, đặc biệt là về hiệu năng. JRE chủ yếu chạy ở chế độ nền, nhưng bạn có thể sử dụng nó để theo dõi ứng dụng và cấu hình bộ nhớ.
JVM là gi? Giới thiệu Java Virtual Machine
JVM quản lý bộ nhớ hệ thống và cung cấp môi trường thực thi di động cho các ứng dụng dựa trên Java
What is JRE?
JRE stands for Java Runtime Environment- also written as Java RTE. It is a set of software tools designed for running other software. It is an implementation of JVM, and JRE provides a runtime environment. In short, a user needs JRE to run any Java program. If not a programmer, the user doesn’t need to install the JDK- JRE alone will help run the Java programs.
All the versions of JDK come bundled up with the JRE (Java Runtime Environment). This way, a user doesn’t have to download and install JRE on their PC separately. The JRE also exists physically. It consists of a library set + a few more files that the JVM (Java Virtual Machine) deploys at the runtime.
Relationship between JVM, JRE, and JDK.
Out of all the programming languages, Java is the most common one for the purpose of development today. Most developers use it for mobile and desktop computing, game development, back-end development, etc. Here, JVM, JRE, and JDK play a crucial role in the development process with Java. Before getting a detailed knowledge of this language, we must know the significant difference between JDK, JRE, and JVM. In this article, we will discuss the same. But first, let’s get a brief overview of them individually.
Ultimate Guide to Kickstart your GATE Exam PreparationDownload the e-book now
What is JVM?
JVM stands for Java Virtual Machine. It provides a runtime environment for driving Java applications or code. JVM is an abstract machine that converts the Java bytecode into a machine language. It is also capable of running the programs written by programmers in other languages (compiled to the Java bytecode). The JVM is also known as a virtual machine as it does not exist physically.
JVM is essentially a part of the JRE (Java Run Environment). You cannot separately download and install it. You first need to install the JRE to install the JVM. It is available for many software and hardware platforms. In various distinct programming languages, the compiler functions to produce machine code for specific systems. However, only the Java compiler produces code for a virtual machine- also known as JVM.
All three, JDK, JRE, and JVM, are dependent. It is because each Operating System’s (OS) condition is different from one another. But Java is independent of the platform. The JVM has three notions: implementation, instance, and specification.
JVM primarily performs the following tasks:
- Provides runtime environment
- Verifies code
- Loads code
- Executes code
Key Difference Between JDK, JRE, and JVM
- JDK is a software development kit whereas JRE is a software bundle that allows Java program to run, whereas JVM is an environment for executing bytecode.
- The full form of JDK is Java Development Kit, while the full form of JRE is Java Runtime Environment, while the full form of JVM is Java Virtual Machine.
- JDK is platform dependent, JRE is also platform dependent, but JVM is not platform independent.
- JDK contains tools for developing, debugging, etc. JRE contains class libraries and other supporting files, whereas software development tools are not included in JVM.
- JDK comes with the installer, on the other hand, JRE only contains the environment to execute source code whereas JVM bundled in both software JDK and JRE.
What is JRE?
JRE is a piece of a software which is designed to run other software. It contains the class libraries, loader class, and JVM. In simple terms, if you want to run Java program you need JRE. If you are not a programmer, you don’t need to install JDK, but just JRE to run Java programs. Though, all JDK versions comes bundled with Java Runtime Environment, so you do not need to download and install the JRE separately in your PC. The full form of JRE is Java Runtime Environment.
What is JRE?
JRE (Java Runtime Environment) is a software package that provides Java class libraries, Java Virtual Machine (JVM), and other components that are required to run Java applications.
JRE is the superset of JVM.
If you need to run Java programs, but not develop them, JRE is what you need. You can download JRE from Java SE Runtime Environment 8 Downloads page.
Just-in Time Compiler (JIT)
JIT compiler is a component that is part of the JVM and hence its implementation JRE. JIT runs when the Java program is interpreted and its objective is to optimize the Java program and make it efficient in terms of performance.
Last Updated on December 11, 2023 by Ankit Kochar
In the world of Java programming, the terminologies JDK (Java Development Kit), JRE (Java Runtime Environment), and JVM (Java Virtual Machine) hold pivotal roles. Understanding the differences among these components is fundamental for Java developers, as they form the backbone of Java application development. Each serves a distinct purpose in the execution and development of Java-based software.
Cấu hình không gian ngăn xếp(Configuring stack space)
Không gian ngăn xếp là nơi các hàm gọi và tham chiếu biến được xếp hàng. Không gian ngăn xếp là nguồn gốc của lỗi nổi tiếng thứ hai trong lập trình Java: ngoại lệ tràn ngăn xếp (đầu tiên là ngoại lệ con trỏ null). Ngoại lệ tràn ngăn xếp chỉ ra rằng bạn đã hết dung lượng ngăn xếp vì quá nhiều phần đã được bảo lưu. Thông thường, bạn sẽ nhận được một ngăn xếp tràn khi một phương thức hoặc phương thức gọi nhau theo kiểu vòng tròn, do đó dành một số lượng lớn các lệnh gọi hàm ngày càng tăng vào ngăn xếp.
Bạn sử dụng công tắc -Xss để định cấu hình kích thước bắt đầu ngăn xếp. Ngăn xếp sau đó phát triển linh hoạt theo nhu cầu của chương trình.
JDK là gì? Giới thiệu Java Development Kit
JDK là một thành phần nền tảng chính để xây dựng các ứng dụng Java. Trái tim của nó là trình biên dịch Java.
Java Development Kit (JDK) là một trong ba gói công nghệ cốt lõi được sử dụng trong lập trình Java, cùng với JVM (Java Virtual Machine) và JRE (Java Runtime Environment)
JRE có thể được sử dụng như một thành phần độc lập để chạy các chương trình Java, nhưng nó cũng là một phần của JDK. JDK yêu cầu JRE vì chạy các chương trình Java là một phần của việc phát triển chúng.
Các định nghĩa:
- Định nghĩa kỹ thuật: JDK là một triển khai của đặc tả nền tảng Java, bao gồm các trình biên dịch và thư viện lớp.
- Định nghĩa hàng ngày: JDK là gói phần mềm bạn tải xuống để tạo các ứng dụng dựa trên Java.
Nguồn tham khảo: https://www.javaworld.com/article/3272244/what-is-the-jvm-introducing-the-java-virtual-machine.html https://www.javaworld.com/article/3296360/what-is-the-jdk-introduction-to-the-java-development-kit.html https://www.javaworld.com/article/3304858/what-is-the-jre-introduction-to-the-java-runtime-environment.html
All rights reserved
We must understand the differences between JDK, JRE, and JVM before proceeding further to Java. See the brief overview of JVM here. If you want to get the detailed knowledge of Java Virtual Machine, move to the next page. Firstly, let’s see the differences between the JDK, JRE, and JVM. JVM (Java Virtual Machine) is an abstract machine. It is called a virtual machine because it doesn’t physically exist. It is a specification that provides a runtime environment in which Java bytecode can be executed. It can also run those programs which are written in other languages and compiled to Java bytecode. JVMs are available for many hardware and software platforms. JVM, JRE, and JDK are platform dependent because the configuration of each OS is different from each other. However, Java is platform independent. There are three notions of the JVM: specification, implementation, and instance. The JVM performs the following main tasks: JRE is an acronym for Java Runtime Environment. It is also written as Java RTE. The Java Runtime Environment is a set of software tools which are used for developing Java applications. It is used to provide the runtime environment. It is the implementation of JVM. It physically exists. It contains a set of libraries + other files that JVM uses at runtime. The implementation of JVM is also actively released by other companies besides Sun Micro Systems. JDK is an acronym for Java Development Kit. The Java Development Kit (JDK) is a software development environment which is used to develop Java applications and applets. It physically exists. It contains JRE + development tools. JDK is an implementation of any one of the below given Java Platforms released by Oracle Corporation: The JDK contains a private Java Virtual Machine (JVM) and a few other resources such as an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), etc. to complete the development of a Java Application. More Details. Next TopicJVM: Java Virtual Machine |
What is JVM, JRE, JDK and JIT
Most of the beginners find it difficult to understand the difference between these jargons. In short,
- Java Virtual Machine (JVM) is an abstract definition of a computing machine.
- Java Runtime Environment (JRE) is the implementation of the JVM.
- Java Development Kit (JDK) is a set of tools using which Java programs can be developed and compiled.
- Just In Time Compiler (JIT) runs on the fly in the execution environment to make optimizations on the program.
Keywords searched by users: jdk and jre and jvm
Categories: Có được 63 Jdk And Jre And Jvm
See more here: kientrucannam.vn
See more: https://kientrucannam.vn/vn/