How to download the most updated java virtual machine(Hotspot) source code? - java

I am going to contribute to Java Community and I am interested in JVM.
Now I would like to download the most updated JVM Hotspot source code and track the updates.
First, I go to http://openjdk.java.net/ .
On its left side I find some useful tag
Source code:
Mercurial
Bundles
...
JDK 6
JDK 7
JDK 7 Updates
JDK 8 · Java SE 8
JDK 8 Updates
JDK 9 · Java SE 9
JDK 10
I can only find instruction about how to download source code of JDK8u: http://openjdk.java.net/projects/jdk8u/
Status
We're open for fixes for 8u152 in the jdk8u-dev forest. (The post time is 2017-06-06 14:23:36)
Source code
The jdk8u-dev forest for ongoing development can be cloned using this command: hg clone http://hg.openjdk.java.net/jdk8u/jdk8u-dev;cd jdk8u-dev;sh get_source.sh .
The corresponding master forest jdk8u can be cloned using this command: hg clone http://hg.openjdk.java.net/jdk8u/jdk8u;cd jdk8u;sh get_source.sh .
In addition, the source code for the last release, 8u102, is available by cloning the 8u master forest : http://hg.openjdk.java.net/jdk8u/jdk8u and using the 'jdk8u102-b14' mercurial tag.
But it appears that jdk9 and jdk10 are also on the list. Are they the most updated source code and how can I download them?
JDK9 page does not provide instructions about how to get source code.
JDK9 : http://hg.openjdk.java.net/jdk9
JDK10: http://openjdk.java.net/projects/jdk10/
Besides, if the Java Community release a new update, what is the best way to update my current source code? Download again or use Mercurial tool?
What is forest in jdk source code? Is it similar to branch in git?
Also, I can find another way to download JVM Hotspot source code from github in JetBrains:
https://github.com/JetBrains/jdk8u_hotspot/tree/d37547149a7c5647ebffbbb62525cc62bd8e2673
But I am not sure this one is the most updated one.

This depends on what you mean by 'most updated'.
Actually, all of jdk8u, jdk9 and jdk10 repositories are kept up-to-date; they are just separate projects having different status and accepting different set of changes.
jdk8u has the most recent changes that will appear in the future updates of JDK 8. These updates mainly consist of bug fixes.
jdk9 repository contains up-to-date code that will be released soon as JDK 9. The project is now in Rampdown phase 2 meaning that only showstopper bugs can be fixed there. It's not defined yet what will happen to this repository after JDK 9 release - e.g. give start for something like jdk9u.
jdk10 contains the ongoing work on future version of Java SE platform. Important improvements made here are likely to be backported to jdk9 sometime later (of course, if they comply with the specifications).
Note that new features are not developed directly in this repository. New features must go through JEP process. Some bigger features may be even hosted in separate projects like Panama or Valhalla.
The official repositories of OpenJDK projects are hosted at http://hg.openjdk.java.net
To get the sources use Mercurial, e.g.
hg clone http://hg.openjdk.java.net/jdk10/jdk10
It contains several nested repositories. HotSpot JVM is under hotspot:
hg clone http://hg.openjdk.java.net/jdk10/jdk10/hotspot
Later you can use hg pull -u to sync your local repository with the updates from the master.
In the parent repository you'll also find the instructions how to get the sources and to build OpenJDK: common/doc/building.md. There is a similar document in jdk9 repo.

Related

Using JJWT on JDK 1.6

On the main page I noticed that JJWT is supposed to run on all JDK, which - since our project for all sorts of reasons is still stuck on v1.6 - sounded great.
With the last version maven retrieves however, the class version is not compatible.
And afterwards in the build wiki I noticed it specifies version 7.
Anyone have a clue what does run on v1.6.
Can I use an older version, or should I compile it myself maybe.
On the main page I noticed that JJWT is supposed to run on all JDK ...
That is definitely incorrect / inaccurate. The initial commits for the JJWT project were for JDK 1.6. And I can see that the code uses generics, so compiling / running for earlier than JDK 1.5 will be impossible.
The POM.xml file for the latest version of the project sets the source and target version for the project to JDK 1.7. So certainly the artifacts that a standard build will generate now will NOT run on a Java 6 platform. The class file version will be too recent for a Java 6 JVM to understand.
Now you could try changing the JDK level to 1.6 in the POM file in the HEAD version. However, the JDK version for JJWT was bumped past 1.6 four years ago, so there are liable to be build issues if you wind back. (The developers could have introduced Java 7+ dependencies; e.g. using try with resources syntax or Java 7+ APIs.)
A better idea would be to use an old version of JJWT. You should be able to figure out what version you need to use (or build) for JDK 1.6 compatibility by looking at the project's git history on Github. Look at the relevant changes to the POM file and when they happened. I think it is version 0.9.0 or thereabouts.
Of course a better solution would be "unstick" your project. JDK 1.6 is 8 years past its end of life, and 3 years past the end of Oracle's JDK 1.6 (paid) extended support.

Why aren't there compatible JREs for JavaSE12+?

I am getting an error when trying to run a .java file as a Java Application and I get the following error:
Unbound classpath container: 'JRE System Library [JavaSE-14]' in project <project_name>
I tried to change the execution environment and for JavaSE12 and later versions there are no compatible JREs. (But for JavaSE11 the compatible JRE is java-11-openjdk-amd64)
I do not know what to do because the project I am working on doesn't work with old Java versions. How can I choose an environment for the latest Java versions?
Note: I am using Ubuntu 20.04 if that makes any difference.
tl;dr
I am not a Linux user, so I may not know best. But I suspect the simplest approach to running your .java file is to:
Obtain and install a JDK for Java 15 for Linux
Call java app on the command-line, passing the path to your .java file.
Backwards-compatibility is a priority for the Java team. Most any existing Java app should be able to run with the latest version of Java. There are exceptions, but they are very few.
JRE is passé
The JRE (Java Runtime Environment) was a subset of the JDK (Java Development Kit), omitting some of the programmer tools. The JRE as a separate product seems to be getting phased out.
Oracle and much of the Java community has shifted away from the idea of regular users having Java installed on their personal computers. Instead, apps should be delivered with a JVM specific to their host platform bundled within the app. This bundling of a JVM can be done using newer tools such as jlink and jpackage.
For more info, read:
Java Client Roadmap Update - Oracle (2020-05)
Java is still Free
Obtain a JDK
You said you have a .java file to execute. That file must first be compiled before it can be executed. The more recent versions of the java app can do both steps at the same time, compile & execute.
First download and install a JVM for your host platform.
Java 11 is the current long-term support (LTS) version. Java 15 is the latest release. You may want to read about the six-month release cadence for Java.
You have a bounty of vendor choices providing implementations of Java. Here is a graphic flowchart I made to assist in choosing a vendor.
If the steps shown here are overwhelming, I suggest either:
Using apt-get or similar package installer to obtain a build of OpenJDK for Ubuntu. I am not a Linux-user, so I do not know the details.
Head over to AdoptOpenJDK to download an installer for Linux.
Some motivations to consider in selecting a vendor.
Compile & run your app
Once your JDK is installed, on a console (such as Terminal.app in macOS), run something like the following. The java command should both compile and execute your .java file, if that single file makes up your entire app.
java /path/to/some/folder/MyJavaApp.java

How to download OpenJDK 8 source code from java.net

I need to have access to the source code of some classes from the sun.* packages of Java 8 for my project. I found it on https://download.java.net/openjdk/jdk8/, but the link is for OpenJDK 8u0. I also found a link to 8u40 (http://download.java.net/openjdk/jdk8u40/ri/openjdk-8u40-src-b25-10_feb_2015.zip) from Googling, but I can't find any page on java.net that references it. How can I find a link to the latest stable OpenJDK 8 version (8u192) source code from java.net or at least something more recent than 8u40?
Please note the following:
I specifically want the source code of OpenJDK 8 because the Oracle JDK source code doesn't contain the sun.* packages that I need.
I'm aware that public updates for Java 8 stop after 8u202 that will be released this month. As I only need the source code for reference, it doesn't matter in my case.
I would prefer OpenJDK directly from Oracle (from java.net) instead of third-party vendors like Adopt or Azul.
This question is not "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource" because I don't ask for any recommendations or opinions. I'm asking for source code for a very specific thing that should be publicly available as OpenJDK is an open source project.
First of all. Oracle JDK is in essence OpenJDK because Oracle handed over (nearly) the whole stuff over to OpenJDK. Oracle JDK can be seen as one VM based on OpenJDK as there are others. What is stopping this month is the free availability of OracleJDK-updates, etc. but that has no effect on the other VMs out there.
The source can be accessed (including newer versions after Oracle stops their free support) at the Mercurial Repositories at http://hg.openjdk.java.net. The sources you're looking for should be available at http://hg.openjdk.java.net/jdk/jdk/tags
Edit: Because you asked in a later comment in your question: You can download the source of a given project by clicking onto one of the links on the left side of the page showing the names of archive-files (bz2, zip tar) at the start-page of a given tag.
Edit2: Because you asked for Java 1.8.0_192 (I assume b26), you can use http://hg.openjdk.java.net/jdk8u/jdk8u-dev/jdk/archive/996dd3ce1ec5.zip. Here are the steps to get to it: From the main page go to the Project jdk8u (http://hg.openjdk.java.net/jdk8u). Select jdk8u-dev->JDK (http://hg.openjdk.java.net/jdk8u/jdk8u-dev/jdk/). Click on "Tags" (http://hg.openjdk.java.net/jdk8u/jdk8u-dev/jdk/tags), select "jdk8u192-b26 " (http://hg.openjdk.java.net/jdk8u/jdk8u-dev/jdk/rev/996dd3ce1ec5) and click on one of the archive-formats on the left, e.g. ZIP (see above).

Creating a new project for Maven Central - What JDK version to use?

Since JDK versions are not backward compatible, i.e. bytecode (*.class) files created with JDK X might not run under JVM X-1 or older (JDK 1.8 bytecode might not run on a JVM 1.5), how can I determine what version of Java should my project be built with if I want to submit it to Maven Central?
If I use the most recent Java and use its latest language feature, my project would not reach most users as the could not run my project with their JVM. However, I do not want to write my software with Java 1 neither. So, how does one determine the JDK version to use? What is the "standard", if there is any?
its better to give it in java 7 so that it can be used in 6 to 8 version but you will lose some Functional Programming apporach
Java 7 is the answer, as of beginning of 2017.
Nothing better than a survey to find out what version of Java is mainly used out there. The following Java Tools and Technologies Landscape Report 2016 article gives some really interesting insights. Apparently, 90% of projects in production use the last two versions of Java (as of this writing, Java 8 at 62% and Java 7 at 28%).
Thus, for Maven Central, it is pretty safe to use the version just below the current one to reach most projects. Ashok Kumar N suggestion to use Java 7 makes perfect sense since it is strongly compatible with Java 6. Thus with Java 7, one can catch 99% of the market.

Organizing github repository for java 6 and 7

I am wanting to create a gihub repository that offers benchmarking code that
works for concurrent features available only in JDK 1.7 (Fork/Join) as well as for older ones found in JDK 1.6.
Offering both options is important for what I need.
Does anyone have a recommendation how should I structure the repository.
I was planning on having a repo called and under it:
jdk17
build
src
mycode ...
jdk16
build
src
mycode
Please suggest any alternatives, possibly use of Maven or other more practical approaches, if any.
Unless you need to have source code for both versions available at the same time, you can just put them in separate branches.

Categories