Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recompile Java Runtime Environment (JRE)?

Tags:

java

I thought this would be very easy. I downloaded the JDK, extracted src.zip, modified the JDK to fit my needs and saved the file.

Now, the only thing I need to do is recompile the extracted and update src folder to a "JRE". I tried using javac, but didn't get anywhere. For example, I got the error that no source files were given. I am obviousely not using the right syntax to compile the JRE.

So, can anyone tell me, how do you end up with a working "JRE" folder containing a modified Java Runtime Environment based on the new source folder extracted from the JDK?

Note: I am not going to redistribute the compilation. It is for personal self use only.

Update: thanks to an answer and http://www.javalobby.org/java/forums/t103334.html I got to the following command: "c:\tmp\jdk1.6.0_17\bin\javac" -classpath "c:\tmp\out" -verbose -g -d "c:\tmp\out" -J-Xmx512m -cp "c:\jdk1.6.0_17\jre\lib\rt.jar";"c:\jdk1.6.0_17\lib\tools.jar" @files.txt - unfortunately, while it does seem to process things, when finished the output folder /out is empty. Is something wrong with my command?

like image 621
Tom Avatar asked Jun 06 '26 18:06

Tom


2 Answers

Set your classpath to the top of the extract source directory. Compile the files then place their .class files back in the rt.jar.

like image 171
Steve Kuo Avatar answered Jun 09 '26 07:06

Steve Kuo


You will not be able to compile the entire Sun/Oracle JDK given just the sources that are supplied with it, because many of those classes internally make use of proprietary classes in packages like com.sun.*, and of course native methods - and the source of these is not included in the JDK. You have to get them via a special source code release or use OpenJDK (and I have no idea whether getting the native stuff to work is trivial or excruciating). Alternatively, it might be possible to selectively recompile only specific classes - but of course only when you don't change them in ways that make them incompatible with existing usage in the JDK.

like image 34
Michael Borgwardt Avatar answered Jun 09 '26 08:06

Michael Borgwardt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!