How does one build the java JRE from source (src.zip in JDK)?

谁说胖子不能爱 提交于 2021-02-16 05:06:33

问题


Surprisingly enough I couldn't find the answer to this question.

I am trying to rebuild the java JRE from source. I obtain the java JRE source by extracting the src.zip file in the JDK.

After making any changes I need to make to the JRE, how do I compile the new source back into .java files (after which I can compress it into the rt.jar file).

Thanks.


回答1:


Some of the Java sources that make up rt.jar are generated during the build process, from scripts and other means. Some of the properties files are also generated this way, and some of the properties files are turned into Java source that also contributes to rt.jar. So without doing a complete build first and populating the 'gensrc' directory, you won't have all the sources that make up rt.jar.

Taken from: http://www.java.net/forum/topic/jdk/java-se-snapshots-project-feedback/it-possible-just-build-rtjar

So when you say javac on all the java files inside src.zip it won't compile as the dependency graph is broken (missing generated files)

Also have a look at this: Where to get full source code for rt.jar?




回答2:


You have better chances using OpenJDK (the base of Oracle/ Sun's future JDKs). http://openjdk.java.net/

But what do you want to change actually? Maybe there is a better way...




回答3:


If you want to change a number of class, you only need to compile those classes. You don't need to compile the whole JDK unless you intend to replace it.

If you just want to patch it, create a JAR of your changed classes and add this to the boot class path.




回答4:


After revisiting the question. Javac on any of those files will allow you to rebuild them. Also you don't compile .java files into .java files they become .class files. You can write an ANT build script to handle the heavy work for you.



来源:https://stackoverflow.com/questions/4948926/how-does-one-build-the-java-jre-from-source-src-zip-in-jdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!