Brucalipto.org

Keep your door open!

How to Create a Portable JDK 1.7 on Windows

| Comments

As a Java developer sometimes I need a version of Java Development Kit (JDK) that is not the one installed on my PC. Oracle Java installer on Windows does too many things that I cannot control (like changing the JVM used by browsers to run applets). As of this writing Java 7 is at version u45 and you can download it from here. Open the downloaded file with 7-zip (in my case was jdk-7u45-windows-i586.exe) and then open the tools.zip you find inside. Extract everything to a convenient path like C:\jdk-1.7u45. Now it is shell time so open a DOS console (Start->Run…->cmd) and type:

Create a portable JDK 1.7
1
2
> cd C:\jdk-1.7u45
> for /r %x in (*.pack) do C:\jdk-1.7u45\bin\unpack200 "%x" "%x.jar"

Now you are almost done but you need to rename some files:

Look for all files that ends with .pack.jar
1
2
3
4
5
6
7
8
9
10
> dir /B /S *.pack.jar
C:\jdk-1.7u45\jre\lib\charsets.pack.jar
C:\jdk-1.7u45\jre\lib\deploy.pack.jar
C:\jdk-1.7u45\jre\lib\javaws.pack.jar
C:\jdk-1.7u45\jre\lib\jfxrt.pack.jar
C:\jdk-1.7u45\jre\lib\jsse.pack.jar
C:\jdk-1.7u45\jre\lib\plugin.pack.jar
C:\jdk-1.7u45\jre\lib\rt.pack.jar
C:\jdk-1.7u45\jre\lib\ext\localedata.pack.jar
C:\jdk-1.7u45\lib\tools.pack.jar

Rename all these files removing the .pack part (eg.: rename charsets.pack.jar to charsets.jar):

Rename all files that ends with .pack.jar
1
2
3
4
5
6
7
8
9
> ren C:\jdk-1.7u45\jre\lib\charsets.pack.jar charsets.jar
> ren C:\jdk-1.7u45\jre\lib\deploy.pack.jar deploy.jar
> ren C:\jdk-1.7u45\jre\lib\javaws.pack.jar javaws.jar
> ren C:\jdk-1.7u45\jre\lib\jfxrt.pack.jar jfxrt.jar
> ren C:\jdk-1.7u45\jre\lib\jsse.pack.jar jsse.jar
> ren C:\jdk-1.7u45\jre\lib\plugin.pack.jar plugin.jar
> ren C:\jdk-1.7u45\jre\lib\rt.pack.jar rt.jar
> ren C:\jdk-1.7u45\jre\lib\ext\localedata.pack.jar localedata.jar
> ren C:\jdk-1.7u45\lib\tools.pack.jar tools.jar

Finally test you new portable JDK 1.7:

Test portable JDK 1.7
1
2
3
4
> .\bin\java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode)

I hope this tutorial can help you… if you find errors please report them to me and I will correct as soon as possible.

Comments