views:

226

answers:

5

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?

Thanks in advance.

A: 

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.

Alex Beardsley
Unless it's OpenJDK. There are also JRL and JIUL licences.
Tom Hawtin - tackline
This is not going to be a problem because I am not going to redistribute the compilation. Updated my question to reflect this.
Tom
+1  A: 

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.

fuzzy lollipop
Interesting. However, I have no idea how to end up with a working JRE now. If I have modified the String.java file for example, how would I end up with a working JRE folder which reflects this change to String.java?
Tom
+2  A: 

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

Steve Kuo
With your suggestion 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?
Tom
+1  A: 

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.

Michael Borgwardt
+1  A: 

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

Pascal Thivent