Java Se 6 VS. Jre 1.6 VS. Jdk 1.6 - What Do These Mean

Java SE 6 vs. JRE 1.6 vs. JDK 1.6 - What do these mean?

When you type "java -version", you see three version numbers - the java version (on mine, that's "1.6.0_07"), the Java SE Runtime Environment version ("build 1.6.0_07-b06"), and the HotSpot version (on mine, that's "build 10.0-b23, mixed mode"). I suspect the "11.0" you are seeing is the HotSpot version.

Update: HotSpot is (or used to be, now they seem to use it to mean the whole VM) the just-in-time compiler that is built in to the Java Virtual Machine. God only knows why Sun gives it a separate version number.

Is Java 1.6 the same as JDK 6?

Yes, they're the same. See this page for a more detailed explanation of the version numbering.

Which one to download: JDK or JRE?

Download the JDK if you want to do Java development. The JDK comes with the Java compiler (javac) which you will need for development.
The JRE is the run time environment only - get this if you only want to run Java programs.
If you get the JDK it comes with a JRE included so you don't need to get the JRE separately.

Java versioning and terminology, 1.6 vs 6.0 OpenJDK vs Sun

The versioning is simply a mess:

  • Java 1.0 and 1.1 were normal
  • Then came Java 1.2, but you were supposed to call it "Java 2, JDK 1.2"
  • This continued until 1.4 (There were also minor releases like 1.4.2)
  • The next version was then supposedly "Java 5.0", but there was still "1.5" all over the place in the file names and URLs.
  • Starting with Java 6, they've dropped the minor version and mostly (but not completely, see output of java -version) eliminated the traces of the old versioning scheme, but people have gotten used to it and continue to use it colloquially.
  • Starting with Java 9 or 10, the 1.X notation also disappeared from the output of java -version (which caused some code that depended on parsing it to break), and people have pretty much stopped using it. We now have Java 15, Java 16, Java 17, etc.

Note also that when this question was asked, Sun JDK and OpenJDK were separate codebases (whith a large overlap), and Sun JDK was the official reference implementation.

In the more than 10 years since then, Java was sold to Oracle, OpenJDK became the official Java reference implementation, and Oracle stopped maintaining the Oracle JDK as a separate codebase. Instead, they just provide OpenJDK builds and provide commercial long term support for them with bugfixes and security patches. But you can also get builds for free from AdoptOpenJDK (which recently rebranded as "Adoptium"), they just aren't supported as long.

Why do some Java programs ask for a JDK and some for the JRE?

Short version: some applications use libraries/code that is contained only in the JDK.

Longer version: Usually every Java program should be able to run with just the JRE. And most applications actually work with the JRE.

Now the JDK comes with some additional libraries and tools that you usually only need when developing applications (and not when you simply need to run them).

But occasionally an application decides to use some of the code that gets delivered with the JDK when it runs. It's very rare and is usually not a good idea (unless that application is itself about developing Java applications).

A good example where old versions of Apache Tomcat: it used the Java compiler bundled with the JDK to compile JSP code into bytecode. For this it used tools.jar which is included in the JDK but doesn't get delivered with the JRE.

Newer Tomcats switched to a separate compiler (I think it's based on the Eclipse compiler) for this and no longer require the JDK: they run just fine with just the JRE.

@Rekin mentioned another good example: Maven uses the JDK because it actually compiles Java code.

Java JDK, SDK, SE?

Yes, it can be confusing.

You didn't ask for it, but I'll start from here. The JVM is the Java Virtual Machine. It is a program that can read compiled Java code (the .class files, and the .jar files that are simply .zip files containing a bunch of .class files packaged together) and execute it. There are many JVMs, for example you need a JVM for Windows, one for Linux, one for OSX etc. but there are also many alternative JVMs, JVMs for embedded device etc. (many will disagree and say that the JVM is only one, and it's a specification. However, commonly a sysadmin will say "the JVM" to indicate the actual binary running on the server).

You didn't ask for the following either. The JRE is the Java Runtime Environment. It includes everything needed to run a Java application, that is the JVM itself, the standard library and a bunch of other files. The standard library is itself very important, because it contains a lot of useful things you'll use when developing Java applications. It contains all the stuff in java.* packages and some private stuff in com.sun, com.oracle packages.

Different versions of Java (1.0, 1.1, etc. all the way to 1.7, also known as Java 7) usually contain improvements to both the JVM and the standard library, so the two usually need to run together, and are packaged together in the JRE.

If you are running any Java program on your computer, you have a JRE installed.

The JDK is the Java Development Kit. It contains the JRE as well as a lot of other useful stuff for developing Java applications. That includes the compiler obviously (which is also contained in the JRE for some good reason, but you can ignore this fact now), the JAR utility to create .jar files, many tools for "decompiling" class files, inspect .jar files, repackage them, etc.

It also usually contains documentation for the standard library and also all the sources of the standard library, because they are useful for developers to read and inspect. If you want to seriously develop Java applications, you need the JDK.

When talking about JavaSE, JavaEE, JavaME etc. those are so called "editions". Basically, since the Java ecosystem is huge, Sun decided to offer Java in different editions:

  • JavaSE: is the standard edition, it is usually a good fit for client side software, normal applications, etc.
  • JavaME: is the mobile edition, it is what small games on old phones was made with, but it's basically a "smaller" version of Java suitable for very low capacity processors.
  • JavaEE: is the "enterprise edition". It is used to develop server side stuff, so it includes a lot of libraries used on server side.

Regarding numbering, they messed it up quite a bit. Actually, after Java 1.4 they created the JCP, to involve the community in the development of Java itself, and starting from Java 1.5 it is officially named "Java 5", despite most in the industry calling it 1.5. Also, Java 1.2 was Java 2, but everyone I know who was not working in Sun at that time always called it 1.2.

What is the difference between JDK and JRE?

The JRE is the Java Runtime Environment. It is a package of everything necessary to run a compiled Java program, including the Java Virtual Machine (JVM), the Java Class Library, the java command, and other infrastructure. However, it cannot be used to create new programs.

The JDK is the Java Development Kit, the full-featured SDK for Java. It has everything the JRE has, but also the compiler (javac) and tools (like javadoc and jdb). It is capable of creating and compiling programs.

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

Sometimes, even if you are not planning to do any Java development on a computer, you still need the JDK installed. For example, if you are deploying a web application with JSP, you are technically just running Java programs inside the application server. Why would you need the JDK then? Because the application server will convert JSP into Java servlets and needs to use the JDK to compile the servlets. I am sure that there are more examples.

What is the difference between JVM, JDK, JRE & OpenJDK?

JVM

The Java Virtual Machine (JVM) is the virtual machine that runs the Java bytecodes. The JVM doesn't understand Java source code; that's why you need compile your *.java files to obtain *.class files that contain the bytecodes understood by the JVM. It's also the entity that allows Java to be a "portable language" (write once, run anywhere). Indeed, there are specific implementations of the JVM for different systems (Windows, Linux, macOS, see the Wikipedia list), the aim is that with the same bytecodes they all give the same results.

JDK and JRE

To explain the difference between JDK and JRE, the best is to read the Oracle documentation and consult the diagram:

Java Runtime Environment (JRE)

The Java Runtime Environment (JRE) provides the libraries, the Java Virtual Machine, and other components to run applets and applications written in the Java programming language. In addition, two key deployment technologies are part of the JRE: Java Plug-in, which enables applets to run in popular browsers; and Java Web Start, which deploys standalone applications over a network. It is also the foundation for the technologies in the Java 2 Platform, Enterprise Edition (J2EE) for enterprise software development and deployment. The JRE does not contain tools and utilities such as compilers or debuggers for developing applets and applications.

Java Development Kit (JDK)

The JDK is a superset of the JRE, and contains everything that is in the JRE, plus tools such as the compilers and debuggers necessary for developing applets and applications.

Note that Oracle is not the only one to provide JDKs.

OpenJDK

OpenJDK is an open-source implementation of the JDK and the base for the Oracle JDK. There is almost no difference between the Oracle JDK and the OpenJDK.

The differences are stated in this blog:

Q: What is the difference between the source code found in the OpenJDK repository, and the code you use to build the Oracle JDK?

A: It is very close - our build process for Oracle JDK releases builds on OpenJDK 7 by adding just a couple of pieces, like the deployment code, which includes Oracle's implementation of the Java Plugin and Java WebStart, as well as some closed source third party components like a graphics rasterizer, some open source third party components, like Rhino, and a few bits and pieces here and there, like additional documentation or third party fonts. Moving forward, our intent is to open source all pieces of the Oracle JDK except those that we consider commercial features such as JRockit Mission Control (not yet available in Oracle JDK), and replace encumbered third party components with open source alternatives to achieve closer parity between the code bases.

Update for JDK 11

An article from Donald Smith try to disambiguate the difference between Oracle JDK and Oracle's OpenJDK : https://blogs.oracle.com/java-platform-group/oracle-jdk-releases-for-java-11-and-later

As mentioned in comments by @Alan Evangelista, Java Web Start has been deprecated by Oracle in Java SE 9 and removed in Java SE 11.

Why Java installs a JRE when a JDK is being installed

The JDKs are versioned and have their own directories, the jre directory just gets the latest version of Java (so if you only updated, you see it install repeatedly) and is shared. It is for all the released applications to run.

If you install once, there is no difference, but if you need a specific version, you can't use the jre



Related Topics



Leave a reply



Submit