48

While going over a java book I came across this phrase:

Different JVMs can run threads in profoundly different ways.

While it's completely understandable to me that code can behave differently depending on the underlying JVM implementation, it does bring up the question.

Why are there multiple different implementations of JVM in the first place?

Why might I, as a developer be dissatisfied with the official JVM implementation that Oracle provides and decide to build up a different one?

8
  • 6
    The Java VM has not been code-frozen since its initial release. There have been many versions. While they might be related, they are all different implementations, and behaviors could from one version to another (sometimes intentionally, sometimes not). – jamesdlin Mar 17 '20 at 2:06
  • 6
    For the same reasons that multiple operating systems exists - Windows is not the perfect platform for everything and everybody. – Thorbjørn Ravn Andersen Mar 17 '20 at 9:16
  • 3
    A better question might be why there aren't as many competing implementations of other languages like PHP and Python. – Barmar Mar 17 '20 at 13:50
  • 13
    @Barmar For Python, there are indeed: besides CPython (reference implementation), there is PyPy, Jython, IronPython, only to name some. – glglgl Mar 17 '20 at 14:07
  • 2
    @JonBentley Yes, but the OP also made an incorrect conclusion in the question. The OP's question was triggered by the "Different JVMs can run threads in profoundly different ways." statement from a book and then started wondering why there might be JVMs from other vendors. "From other vendors" isn't even relevant to the quoted statement. – jamesdlin Mar 17 '20 at 21:57
125

Why might I, as a developer be dissatisfied with the official JVM implementation that Oracle provides and decide to build up a different one?

Which one? Oracle has at least three different official JVM implementations!

A couple of reasons why one might develop a JVM implementation are:

  • Platform support: you want to run Java on a platform for which Oracle does not provide a JVM. That is the main reason for the existence of IBM J9, for example.
  • Resource usage: you want to run Java on a device that doesn't have enough resources to run Oracle HotSpot. That's the reason for the existence of Oracle Squawk and Oracle KVM (the "K" stands for "Kilobyte", indicating that this JVM is designed to run on machines with only a few kilobytes of RAM – try that with HotSpot!), and many, many, many others.
  • Performance: Oracle HotSpot isn't fast enough / scalable enough / predictable enough for you. This is the reason for the existence of Azul Zing or WebSphere with the Metronome GC.
  • Licensing: maybe you don't like Oracle's licensing policy. That was the reason for the existence of Apache Harmony, and the various projects that made up GNU's Java implementation efforts (GCJ, Classpath).
  • Competition: Monocultures are bad. Competition sparks innovation.
  • Execution modes: Maybe you prefer Ahead-of-time compilation? That's the reason for the existence of Excelsior JET.
  • Research: there are many research JVMs, such as the Jikes RVM or Oracle Maxine.
7
  • 14
    Slightly O/T, but can you link to Oracle's three "official JVM implementations"? – skomisa Mar 17 '20 at 15:43
  • 2
    An important note re "performance" is that different versions of the JVM are optimized for different usage scenarios. If one implementation takes 100 milliseconds to run a piece of code the first time, and 0.01 milliseconds per time thereafter, while another takes 1 millisecond every time, the latter might be about 100 times as fast if the piece of code runs only once, but the former might be almost 100 times as fast if the piece of code runs a million times. – supercat Mar 17 '20 at 21:37
  • Note that the earlier licensing policies required payment for many uses, so there were many more reasons not to like them. As far as starting of Android project mobile use required commercial license, so Android got its own JVM too. And they've recently become stricter again, but there is now the OpenJDK that didn't exist bak where GCJ and such were created. – Jan Hudec Mar 17 '20 at 22:15
  • 1
    @skomisa The answer names three Oracle JVM implementations (HotSpot, Squawk, KVM). – TRiG Mar 18 '20 at 11:46
  • 1
    @Jimmy JRockit hasn't been a product in almost a decade by now, not sure we would really want to count that ;) (There's Graal for another Oracle JVM though) – Voo Mar 18 '20 at 15:05
22

Java is a spec, not a product

Java is not a specific product or binary. The Java platform is defined by a set of specifications for the language and the JVM, plus JSRs and JEPs.

You said:

the official JVM implementation that Oracle provides

There is nothing "official" about any particular Java implementation. Any implementation that fully implements the specs can run any app written for Java.

The three implementations provided by Oracle are not any more "official" than any other vendor’s implementation.

To understand more detail about Java implementations and vendors, read the white paper: Java is Still Free.

Java™ is a trademark

The word “Java” is trademarked by Oracle. An implementation wishing to use that trademark must come to terms with Oracle. In the past those terms included passing an extensive suite of automated tests, plus presumably paying a fee.

Most of the vendors providing a Java implementation choose to not use the Java™ trademark, instead using the OpenJDK terminology when labeling their distribution.

And speaking of testing suites, the AdoptOpenJDK project has announced their own comprehensive testing suite to be used for builds of OpenJDK. Known as AQA, pronounced "aqua". Their goal to provide tests that are open-source, transparent, diverse, robust, and freely available.

OpenJDK

Nowadays, every Java implementation I know of is based largely, if not entirely, on the OpenJDK project.

FYI, Oracle has declared that “There will be zero differences between the OpenJDK and the Oracle JDK”. The company has even open-sourced their previously commercial tools such as Flight Recorder and Mission Control through the OpenJDK project.

Adoptium (AdoptOpenJDK)

The OpenJDK project produces only source code. You can make your own build from that source code.

Most folks would prefer to get an installer or binary already built. To satisfy that need, several of the vendors listed below have banded together with others to support the AdoptOpenJDK project, now known as Adoptium.

Some of the vendors provide the Adoptium builds directly to their customers. Some vendors may add value to the Adoptium builds. And of course some vendors produce their own builds entirely separate from the Adoptium project.

Adoptium is a good place to start if you are new to Java and have no reason yet to select a particular vendor. Later, if you develop reasons to select a particular vendor such as wanting to purchase support, you can always switch. Your app and your tools will work with any implementation of Java that complies with the Java specifications.

Originally backed by the London Java User Group, the project is now run by the Eclipse Foundation. See the About page of the AdoptOpenJDK/Adoptium site for more details.

More considerations

The Answer by Jörg W Mittag is correct. I would add a few more considerations: price, support plans, and convenience.

Price

Over the years, there have been many Java implementations. They have varied in price. Some are free-of-cost, and some require a fee.

Take, for example, Oracle’s popular Oracle JDK product. As of April 16, 2019, Oracle changed the licensing terms. A fee is now required for use in production, while still free-of-cost for development, testing, and such. People unwilling to pay that fee for use in production must either (a) use another Oracle product without a fee such as jdk.java.net, or (b) look to an alternative vendor such as those listed in the flow chart below.

Support plans

Some users of Java want the security of having a vendor to call when a problem arises. Some want a promise that a critical security vulnerability or technical bug will be patched as quickly as possible (as discussed on another Question). For either of these reasons, some people may want to purchase a support plan.

Some vendors of Java implementations provide such a support service, and some do not.

Convenience

Some people with an established relationship to a particular vendor might enjoy the simplicity of obtaining Java from that same vendor.

For example, Red Hat / IBM provides their own downloads of a Java implementation based on the OpenJDK while at the same time also actively supporting the AdoptOpenJDK project which also distributes builds and installers of OpenJDK.

Flow chart

Here is a flow chart I created to walk people through the various options to consider in choosing a vendor for their Java implementation.

Flowchart guiding you in choosing a vendor for a Java 11 implementation

And here is a list of possible motivations one might have for choosing a vendor.

Motivations in choosing a vendor for Java

5
  • 1
    +1, but it's not clear why "an implementation wishing to use that trademark must come to terms with Oracle" isn't a contradiction of the claim that the Oracle implementation isn't the official one. If you need Oracle's permission to use the word "Java" (which you presumably need to use if you create an implementation) then in some sense their version is the official one. I'm not arguing that that is the case, but rather that the answer could be clearer on this point. – Jon Bentley Mar 17 '20 at 21:28
  • 1
    @JonBentley A trademark is just a trademark, a name used for marketing and advertising. I don’t see how that mere label makes an implementation any more “official”. I’m not arguing against your point, I just don’t know how to make it any more plain and clear. If you have a specific solution to suggest, please do so. – Basil Bourque Mar 17 '20 at 21:37
  • 6
    The second image looks suspiciously like an Adopt advertising (though there does not seem to be any financial interest in that as it is free). – Jan Hudec Mar 17 '20 at 22:19
  • 2
    @JanHudec No, not an advertisement. The broad usefulness of AdoptOpenJDK as seen in that graphic is the natural outcome of the wide support for the project across much of the Java community including most of the other vendors lending their support. The only conspiracy you’ve uncovered is the wide-ranging cooperation of the Java community converging in the founding and support of that project. – Basil Bourque Mar 17 '20 at 22:27
  • 1
    @BasilBourque I think you should make it very clear that AdoptOpenJDK is your personal preference in the "I don't care" case. Not that it is necessarily wrong or right, but it is your personal opinion. – Thorbjørn Ravn Andersen Mar 18 '20 at 21:56
0

JVM is an abstraction. It's a software layer specifically designed to allow the Java language to be platform-agnostic by relying on the existence of a specs-compatible runtime engine "everywhere."

But ... one size does not fit all. If you're trying to "wedge" Java into a very small environment, such as an underpowered (but cheap) Android-style mobile phone, you might have to "bum code" very considerably more than Official Oracle™ found it necessary to do. You might need to develop a JVM implementation that never existed yet.

And so, that's why there are many JVMs. They are architecture- and situation-specific, so that Java doesn't have to be.

-2

It’s called competition. If I think I can create a JVM that is sufficiently better and make money selling it, that’s what I will do.

7
  • 14
    I'm fairly sure that it'll be VERY hard to make money selling a product that has a dozen or so free alternatives, including one from the official maintainers. The company I work for is faced with that issue: a couple years ago a free alternative for our product appeared and now we're faced with heavy competition. – Nzall Mar 16 '20 at 20:56
  • 6
    @Nzall Occasionally it is possible to thrive by excellence. JetBrains can do this with their products. – Thorbjørn Ravn Andersen Mar 17 '20 at 9:18
  • @ThorbjørnRavnAndersen Though to be fair, NetBeans, one of the most popular Java IDEs, has had such major blunders in the past (e.g. not running on the latest java version, etc.) that it's not surprizing people would rather go for paid options. – MechMK1 Mar 17 '20 at 19:13
  • 1
    @mechMK netbeans has done surprisingly well given that Oracle already had a Java ide before they acquired Sun. The blunders happened when Netbeans was finally orphaned by oracle and they had to migrate to Apache requiring full open source. That same move stalled Java development for years back around Java 6. But to be frank, the de facto free java ide today is eclipse (backed by IBM). – Thorbjørn Ravn Andersen Mar 17 '20 at 20:29
  • 4
    @AndresF. I don't think that contradicts what Nzall wrote. He didn't rule it out, he merely said it will be "very hard". What you've described is indeed hard. You'd have to put in the work to come up with a complete implementation and find optimisations that are missing from all the free alternatives and find buyers for your product. – Jon Bentley Mar 17 '20 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.