开发者

How to recompile Java Runtime Environment (JRE)?

开发者 https://www.devze.com 2022-12-22 11:16 出处:网络
I thought this would b开发者_运维知识库e very easy. I downloaded the JDK, extracted src.zip, modified the JDK to fit my needs and saved the file.

I thought this would b开发者_运维知识库e 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?

Thanks in advance.


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


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.


For example, I got the error that no source files were given.

You have to tell javac about every .java file in that you want to compile. javac is telling you that you didn't provide any files for it to compile.


Just in case, you could compile OpenJDK following their instructions or using IcedTea (they also provide guidance to build OpenJDK without the IcedTea harness).


As per Sun's license:

Java Technology Restrictions. You may not create, modify, or change the behavior of, or authorize your licensees to create, modify, or change the behavior of, classes, interfaces, or subpackages that are in any way identified as "java", "javax", "sun" or similar convention as specified by Sun in any naming convention designation.

In other words, you aren't allowed to redistribute modified copies of the JVM, in any form. If you want to do this, you need to contact Sun about licensing.

EDIT: @Tom Hawtin is right; this only applies to Sun's official "vanilla" JRE, i.e. the one end-users have installed on their computers.


Instead of

"c:\tmp\jdk1.6.0_17\bin\javac" -classpath "c:\tmp\out" -verbose -g -d "c:\tmp\out" -J-Xmx512m -cp 

Try The following:

set path=C:\tmp\jdk1.6.0_17\bin

hit the return key on your computer and then the following for the class

C:\tmp>set classpath=.

Again hit the return key on your computer key board and then to compile

C:\tmp>javac YourProgramName.java

To run your program

C:\tmp>java YourProgramName
0

精彩评论

暂无评论...
验证码 换一张
取 消