admin管理员组

文章数量:1202044

I need to build OpenJDK on Linux x64. The main idea is not to use any precompiled BootJDK and build the jdk itself. Precompiled means compiled by someone else (Build by OpenJdk for example /). I need it to build an rpm package into one distribution what based on RHEL. I give link on Fedora Packaging Guidelines, what explain why I don't want to use precompiled archive (). This documentation says that there may be exceptions where it is impossible to build something without external binaries (something like gcc or other compilators). Taking these exceptions into account, other necessary utilities are already in the repositories (make, gcc etc), only the jdk itself is missing.

I just wanted to know possibility to overcome this exception when building the jdk.

So my question: is it possible to somehow build jvm from sources, and then build the rest of jdk based on this build?

Maybe I'm wrong, but looks like jvm is written in C and C++ (сorrect me if I'm wrong). In that case nothing should prevent from compiling it without jdk itself, for example using "gcc".

"make" accepts target hotspot, but configure script still checks for BootJDK and does not allow to proceed further. So I'm stuck here

I need to build OpenJDK on Linux x64. The main idea is not to use any precompiled BootJDK and build the jdk itself. Precompiled means compiled by someone else (Build by OpenJdk for example https://jdk.java.net/archive/). I need it to build an rpm package into one distribution what based on RHEL. I give link on Fedora Packaging Guidelines, what explain why I don't want to use precompiled archive (https://docs.fedoraproject.org/en-US/packaging-guidelines/what-can-be-packaged/#prebuilt-binaries-or-libraries). This documentation says that there may be exceptions where it is impossible to build something without external binaries (something like gcc or other compilators). Taking these exceptions into account, other necessary utilities are already in the repositories (make, gcc etc), only the jdk itself is missing.

I just wanted to know possibility to overcome this exception when building the jdk.

So my question: is it possible to somehow build jvm from sources, and then build the rest of jdk based on this build?

Maybe I'm wrong, but looks like jvm is written in C and C++ (сorrect me if I'm wrong). In that case nothing should prevent from compiling it without jdk itself, for example using "gcc".

"make" accepts target hotspot, but configure script still checks for BootJDK and does not allow to proceed further. So I'm stuck here

Share Improve this question asked Jan 21 at 21:50 SemyonSemyon 131 silver badge4 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

No, this isn't possible. Many parts of the JDK are written in Java, including the Java compiler (javac). When you run javac, it actually starts a JVM which then compiles the application.

In GraalVM, even the JIT compiler is written in Java which may be included in the normal JDK builds in the future (it's already included in OracleJDK 23.

So even though some things are written in C/C++, significant parts are written in Java so you need a boot JDK to build a JDK:

Paradoxically, building the JDK requires a pre-existing JDK. This is called the "boot JDK". The boot JDK does not, however, have to be a JDK built directly from the source code available in the OpenJDK Community.

Which JDK you are using doesn't matter for this as long as its the right version (i.e. use the JDK version below the one you want to build or the same version). For example, if you want to build JDK 21, you can download JDK 20 or 21 from a vendor like Eclipse Adoptium and use that for building. You only need it for the building process (which will probably take a bit of time).

本文标签: javaBuild jvm without jdkStack Overflow