How to download OpenJDK 8 source code from java.net - java

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).

Related

javac: invalid target release: 13

I have been working on some class projects on a work computer with NetBeans 11 and uploading my progress to github. Recently, I came home and pulled my progress down to my laptop which still has netbeans 8. All of a sudden, when I try to run code, I get:
javac: invalid target release: 13
From browsing stackoverflow and other such forums, I gather that 13 refers to the version of the JDK. Apparently, there is some mismatch in my settings (either I am using an old version but NetBeans wants to use something newer, or maybe the other way around).
I went into project > properties > sources and saw a drop down bar titled "Source/Binary Format" with JDK 13 selected. I dropped it down to 9 (a completely random choice) and then tried to run my code again. Voila, it worked.
My questions are simply: What did I just do? Why did it work? Are there any implications for my program to be considered?
If you choose to answer please be aware that I know little about the inner workings of Java, and so a simple explanation is appreciated. I only know how to write the code, not what happens behind the scenes. I'm tempted to blindly plow forward with my coding, but I thought this might be a learning point. Perhaps not.
Basically, your IDE checks your code according to the rules of the language, and those those are different depending on language version because e.g. Java 7 has no lambdas but Java 8 does. Your project was configured to be checked against the rules for Java 13, but the older version of NetBeans wasn't able to do that, so you've asked for it to be checked against the rules for Java 9 instead. This will have no impact on your project unless you want to use features introduced in Java 10 or later.
The other purpose of this drop-down menu is if you want to compile your project so that it can be run using an older version of Java. If you're distributing a piece of software for users who still only have Java 8 installed, then you would want to limit the project to Java 8.

target specific java update with maven

I have an application which I would like to deploy, compiled for java 1.8.0_151. However, the user has only 1.8.0_25. User cannot launch the app because LocalDateStringConverter is missing.
As written here (https://docs.oracle.com/javase/8/javafx/api/javafx/util/converter/LocalDateStringConverter.html) this class has been added only in 8u40
How can I compile (is it possible?) a jar with dependencies for the specific java version of the user?
Or maybe I misunderstood something, new to java here
EDIT I tried specify the pricise version with update number in my pom.xml but it didn't help
There are a two ways to approach this:
You have to set your environment to use the JDK that is expected by the user. In this case 1.8.0_25 - you need to develop all logic using this JDK and the classes available in it. If LocalDateStringConverter is your only dependency missing, you can easily find out the source code and duplicate the logic inside your project as utility class and use that instead.
You can ask/help/advise your user to upgrade their environment to more recent JDK version (security reasons and such). As you are aware most software has minimum requirements to run and it's expected from the end user to meet those requirements in order to run the software.
As already mentioned you can use the Maven Enforcer Plugin to enforce specific java version, but this will not make the functionality from 1.8.0_151 available in 1.8.0_25.
Compiling your code with 1.8.0_25 and hoping that the newer versions are backward compatible is probably the easiest solution. Assuming you have automated tests this will catch problems like a missing class.
The other option would be to build an executable bundle containing both your application and the entire JRE 1.8.0_40 or newer. This is going to result in your software bundle growing by dozens of MBs so I would not recommend it. However one way to do it would be to use Launch4j as advised here.
You can try implementing your own LocalDateStringConverter but how many other classes are you missing? What if there are other subtleties in behaviour between versions? Based on java.com 1.8.0_25 was released on October 14, 2014 while 1.8.0_151 on October 17, 2017. That's 3 years of Java development that your user is missing.

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

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.

Where can I get (matching) sources for com.sun.jndi.ldap.* packages?

I am on JDK6_u26 and don't find com.sun.jndi.ldap package sources as part of sources.zip.
I believe they could be available from OpenJDK6 project, but I am not sure; and I am reading that the sources don't match the binaries in some cases.
Can someone shed some light as to how to get the sources (and if possible,exact matching the JDK binary build) for these packages for attaching them in the debugger?
A URL link/pointer would be great...
Thanks a lot in advance!
See here, "Java SE 6 JDK Source Code" section. You have to sign the Community Licence in the process. NB This download contains much more than the src.zip provided with the JDK.
Since EJP's answer does not lead to a correct place any more, I give my answer here:
We can downlaod openJDK 8 here, note that up to now the latest version is openJDK 8, in case that in the further we want to download the latest version, replace the number 8 in http://download.java.net/openjdk/jdk8/ with the current version number, and go that link and we can find the source code download link.
Then we can find this package at openJDK/src/openjdk/jdk/src/share/classes/com/sun/jndi/ldap/.
For example, the connection pool is in openJDK/src/openjdk/jdk/src/share/classes/com/sun/jndi/ldap/pool/Pool.java

Obtain and download Javadoc (JDK documentation) to a local file for offline reading

When writing Java code, I refer extensively to the Javadoc—that is, the Java® Platform, Standard Edition & Java Development Kit Version x API Specification. I know how to read it online from the website, but I would like to download a copy to my computer so that I can read it offline when no Internet connection is available.
How can I download the documentation? Is there a way to "download" the Javadoc (JDK documentation) from an online site to a local file?
The online docs I am using tend to reject clients such as Eclipse, making work difficult, so I need to pull them onto my machine and attach them to my library JAR.
Links to JDK documentation
Java SE
Download
Web
Other
21 (Early-Access)
Not yet available
Javadoc
Project page
20 (Early-Access)
Not yet available
Javadoc
Project page
19 (current) 🟢
Downloads page
Javadoc
Doc home
18
Downloads page
Javadoc
Doc home
17 (LTS)
Downloads page
Javadoc
Doc home
16
no longer available
Javadoc
Doc home
15
no longer available
Javadoc
Doc home
14
no longer available
Javadoc
Doc home
13
no longer available
Javadoc
Doc home
12
no longer available
Javadoc
Doc home
11 (LTS)
Downloads page
Javadoc
Doc home
10
no longer available
Javadoc
Doc home
9
no longer available
Javadoc
Doc home
8 (LTS)
Downloads page
Javadoc
Platform homeDoc home
7
no longer available
Javadoc
Doc home
6
no longer available
Javadoc
Doc home
Also of interest:
Release Notes
History of Java SE versions
First, make sure they don't already offer an download in zip form or similar.
Then, make sure you are actually allowed to do this (this may depend on where you live, and on any conditions mentioned on the web site from where you want to pull this).
Then, have a look at the Wget tool. It is part of the GNU system, thus included in many Linux distributions, but also available for Windows and Mac, I suppose.
Something like this works for me:
wget --no-parent --recursive --level inf --page-requisites --wait=1 \
https://epaul.github.io/jsch-documentation/simple.javadoc/
(without the line break; it should be escaped by the \ backslash here).
Look up what each option does in the manual before trying this.
If you want to do this repeatedly, look into the --mirror option.
For downloading other websites, --convert-links might also be useful, but I found that is not needed for Javadocs, which usually have the correct absolute and relative links.
This downloads lots of the same copy of the index.html file with appended ?... names (for the FRAMES links on each page). You can remove these files after downloading by adding the --reject 'index.html\?*' option, but they still will be downloaded first (and checked for recursive links). I did not yet find out how to avoid downloading them at all. (See this related question on Server Fault.)
Maybe adding the right recursion level would help here (I didn't try).
After downloading, you might want to zip the resulting directory to take less disk space. Use the zip tool of your choice for this.
For any Javadoc (not just the ones available for download) you can use the DownThemAll addon for Firefox with a suitable renaming mask, for example:
*subdirs*/*name*.*ext*
https://www.downthemall.org/main/install-it/downthemall-3-0-7/
It's possible to use some older versions of the DownThemAll add-on with Pale Moon browser.
You can use something called Dash: Offline API Documentation for Mac. For Windows and Linux you have an alternative called Zeal.
Both of them are very similar. And you can get offline documentation for most of the APIs out there like Java, Android, Angular, HTML5, etc. ... almost everything.
I have also written a post on How to install Zeal on Ubuntu 14.04
update 2019-09-29: Java version 11
The technique below does not now work with Java 11, and probably higher versions: there is no way of ignoring multiple "broken links" (i.e. to other classes, other APIs). Solution: keep your javadoc executable file (or javadoc.exe) from Java version 8
There are good reasons for making your own local javadocs, and it's not particularly difficult!
First you need the source. At the time of writing the Java 8 JDK comes with a zip file called src.zip. Sometimes, for unexplained reasons, Oracle don't always include the source. So for some older versions (and who knows about the future) you have to get hold of the Java source in another way. It's worth also being aware that, in the past, Oracle have sometimes included the source with the Linux version of the JDK, but not with the Windows one.
I just unzipped this file... the top directories are "com", "java", "javax", "launcher" and "org". Directory launcher contains no files to document.
You can generate the javadocs very very simply from any or all of these by CD'ing at the command prompt/terminal to the directory ...\src. Then go
javadoc -d docs -Xmaxwarns 10 -Xmaxerrs 10 -Xdoclint:none -sourcepath . -subpackages java:javax:org:com
NB note that there is a "." after -sourcepath
Simple as that. Generating your own javadocs also has 2 huge advantages
you know they are precisely the right javadocs for the JDK (or any exernal jar file) you are using on your system
once you get into the habit, reconstituting
your Javadocs is not a tiresome challenge (i.e. where to go looking for them). For example I just unzipped a couple of source jars whose packages are closely coupled, so their sources were in effect "merged" & then made a single Javadoc from them...
NB Swing is semi-officially DEAD. We should all be switching to JavaFX, which is helpfully bundled with Java 8 JDK, but in its own source file, javafx-src.zip.
Unzipped, this reveals 3 "root" packages: com, javafx and netscape (wha'?). These should be manually moved over the to appropriate places under the unzipped src directory (including the JavaFX com.sun packages under the Java com.sun strcture). Compiling all these Javadoc files took my machine a non-negligible time. I'd expect to see all the JavaFX source classes in with all the other source classes some time soon.
BTW, the same thinking applies to documenting any and all Java jars (with source) which you use. However, all versions of most jars will be found with their documentation available for download at Maven Central http://search.maven.org...
PS afterthought: using Eclipse and the "Gradle STS" plugin: the "New Gradle STS Project" wizard will create a gradle.build file containing the line
include plugin: 'eclipse'
This magically downloads the source jar with the executable jar (under GRADLE_HOME) when you go
./gradlew build
[addendum 2020-01-13: if you have chosen not to include the Eclipse plugin in your build.gradle, it would appear that you can go (with the selection on your project in the Project Explorer) Right-click Gradle --> Refresh Gradle Project to get Eclipse to download the source files.]
... giving you an extra degree of certainty that you have got the right src and therefore the right javadoc for the dependency in question.
I have used Javadoc packaged by Allimant since I was in college.
The Javadoc is in the CHM format (standard Windows help format), so it's the best viewed when you're using Windows.
For the download of latest Java documentation (JDK 8u77) API
Navigate to http://www.oracle.com/technetwork/java/javase/downloads/index.html
Under Addition Resources and Under Java SE 8 Documentation,
click the Download button.
Under Java SE Development Kit 8 Documentation → Java SE Development Kit 8u77 Documentation.
Accept the License Agreement and click on the download ZIP file.
Unzip the downloaded file
Start the API documentation from jdk-8u77-docs-all\docs\api\index.html
For the other Java versions API download, follow the following steps.
Navigate to http://docs.oracle.com/javase/
From Release dropdown, select either of Java SE 7/6/5.
In corresponding Java SE page and under Downloads left side menu,
click JDK 7/6/5 Documentation or Java SE Documentation.
Now on the next page, select the appropriate Java SE Development Kit 7uXX Documentation.
Accept License Agreement and click on Download ZIP file.
Unzip the file and start the API documentation from
jdk-7uXX-docs-all\docs\api\index.html.
In this case ... make your own javadocs!
First you need the source. At the time of writing the Java 8 JDK comes with a zip file called src.zip. Sometimes, for unexplained reasons, Oracle don't always include the source. So for some older versions (and who knows about the future) you have to get hold of the Java source in another way. It's worth also being aware that, in the past, Oracle have sometimes included the source with the Linux version of the JDK, but not with the Windows one.
I just unzipped this file... the top directories are "com", "java", "javax", "launcher" and "org". Directory launcher contains no files to document.
You can generate the javadocs very very simply from any or all of these by CD'ing at the command prompt/terminal to the directory ...\src. Then go
javadoc -d docs -Xmaxwarns 10 -Xmaxerrs 10 -Xdoclint:none -sourcepath
. -subpackages java:javax:org:com
NB note that there is a "." after -sourcepath
Simple as that. Generating your own javadocs also has the huge advantage that you know they are precisely the right javadocs for the JDK you are using on your system.
The same applies to documenting any and all Java .jars (with source) which you use. However, all versions of most jars will be found with their documentation available for download at Maven Central http://search.maven.org...
JavaFX API documentation
You could download the Mac 2.2 preview release from here and unzip it.
http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html
The Javadoc won't quite match 2.1, but it will be close and if you use the preview instead, it will match exactly.
For the download of latest java documentation(jdk-8u77) API
Navigate to http://www.oracle.com/technetwork/java/javase/downloads/index.html
Under Addition Resources and Under Java SE 8 Documentation
Click Download button
Under Java SE Development Kit 8 Documentation > Java SE Development Kit 8u77 Documentation
Accept the License Agreement and click on the download zip file
Unzip the downloaded file
Start the API docs from
jdk-8u77-docs-all\docs\api\index.html
For the other java versions api download, follow the following steps.
Navigate to http://docs.oracle.com/javase/
From Release dropdown select either of Java SE 7/6/5
In corresponding JAVA SE page and under Downloads left side menu
Click JDK 7/6/5 Documentation or Java SE Documentation
Now in next page select the appropriate Java SE Development Kit 7uXX Documentation.
Accept License Agreement and click on Download zip file
Unzip the file and Start the API docs from
jdk-7uXX-docs-all\docs\api\index.html
The updated latest version of "The Java language Specification" can be found via the following links.
Java 7
Java 8
For example, Java Platform Standard Edition 7 Documentation has a link to download "JDK 7 Documentation" in the sidebar under "Downloads". I'd expect the same for other versions.

Categories