How to install a (portable) JDK in Windows without admin rights

It recently happened to me that I was stuck at work on a Windows installation without access to admin privileges. While I could use a bunch of portable apps I could not find a portable JDK. To get a portable JDK without admin privileges in Windows you have to follow three simple steps.

1. Download

Download the JDK from Oracle (e.g. JDK 8 8u111).

 

2. Extract

If you want to use the x86 version simply open the .exe file with 7-Zip. It contains a single file tools.zip, which contains all the files we need.
Open with 7-Zip

For x64 the tools.zip can be found in .rsrc\1033\JAVA_CAB10\111\

Extract the tools.zip to the desired JDK directory (e.g. “D:\JavaJDK\”).

 

3. Unpack

Now we need to unpack a few files packed with pack200. We do that by executing this script in a console window inside the root of the JDK directory (e.g. “D:\JavaJDK\”):

for /R %f in (.\*.pack) do @"%cd%\bin\unpack200" -r -v -l "" "%f" "%~pf%~nf.jar"

 

Congrats you now have a working, portable JDK!

JAVAC is working

24 thoughts on “How to install a (portable) JDK in Windows without admin rights

  1. Well I’ve tried your solution but I do not have any “tool.zip” inside the “jdk-8u112-windows-x64\.rsrc\1033\JAVA_CAB10”
    or in the whole directory package.
    Is there a change in the structure since JDK 1.8.0_112?

    Even if I try to use the unpack200.exe I always get the following error if I try the following command for example:

    “C:\Program Files\Java\jre1.8.0_112\bin\unpack200.exe” -r “C:\Users\z003mczc\Desktop\jdk-8u112-windows-x64\.data” “C:\temp\Java\new\.data.jar”

    Corrupted pack file: magic/ver = 50A30740/0.1 should be CAFED00D/150.7 OR CAFED0
    0D/160.1 OR CAFED00D/170.1 OR CAFED00D/171.0

    Does anyone else has those issues?

    • Did you follow the instructions as shown in the video? The tools.zip can be found in .rsrc\1033\JAVA_CAB10\111\ for JDK 8u112 x64. Maybe use a newer version of 7-zip (I used 7-Zip 16.04).

      • Hi thanks for your response and sorry it took so long with my answer. So it seems my download failed twice and thats why the exe was corrupt. Now I see the tools.zip you’ve mentioned.

        Thanks for your great article 🙂

  2. Thanks much for your valuable answer. Above trick works fine but I am getting problem in setting the environment variable. Please help me to “set environment variable without admin rights” because for Eclipse IDE(project perspective).

    • 1) Create C:/temp/explorer.bat file:
      set JAVA8_HOME=c:\temp\programs\java\jdk1.8.0_31
      set JAVA_HOME=%JAVA8_HOME%
      set PATH=%PATH%;%JAVA_HOME%\bin;
      cmd /C explorer.exe

      2) Open cmd.exe.
      3) Open windows task manager. Kill exproler.exe.
      4) Execute in cmd.exe window C:/temp/explorer.bat.
      5) Close cmd.exe window.

      It will need to do every reset windows (.

  3. It’s a very useful tip.
    Please note that it is not true anymore, the latest distribution of the jdk isn’t packaged this way.

    • Using the newest version of 7-Zip (Version 16.04 64-Bit) I could use this method on the newest JDK jdk-8u101-windows-i586.exe as well as jdk-8u101-windows-x64.exe.

      • The latest 111 and 112 JDK 8 versions at this point are packaged in a different way, but we can still download version 101 from the Oracle archive

        • For the x86 installer it still works the same, but for x64 installer the tools.zip is located inside .rsrc\1033\JAVA_CAB10\111\. I will update the post later. Thanks!

  4. I’m confused can somebody help me?

    this is whats in the cmd
    Microsoft Windows [Version 10.0.10586]
    (c) 2015 Microsoft Corporation. All rights reserved.

    C:\WINDOWS\system32>C:\Users\jaden\Downloads\7-ZipPortable\App\7-Zip cd\
    ‘C:\Users\jaden\Downloads\7-ZipPortable\App\7-Zip’ is not recognized as an internal or external command,
    operable program or batch file.

    C:\WINDOWS\system32>cd\

    C:\>cd users\

    C:\Users>cd jaden\

    C:\Users\jaden>cd downloads\

    C:\Users\jaden\Downloads>cd 7-zipportable\

    C:\Users\jaden\Downloads\7-ZipPortable>cd app\

    C:\Users\jaden\Downloads\7-ZipPortable\App>cd 7-zip\

    C:\Users\jaden\Downloads\7-ZipPortable\App\7-Zip>for /R %f in (.\*.pack) do @”%cd%\bin\unpack200″ -r -v -l “” “%f” “%~pf%~nf.jar”

    C:\Users\jaden\Downloads\7-ZipPortable\App\7-Zip>

  5. Thanks. I replaced
    for /R %f in (.\*.pack) do @"D:\JavaJDK\bin\unpack200" -r -v -l "" "%f" "%~pf%~nf.jar"
    with
    for /R %f in (.\*.pack) do @"%cd%\bin\unpack200" -r -v -l "" "%f" "%~pf%~nf.jar"
    to avoid typing a long path.

  6. Thanks nick, this helped me on laptop where i couldnt install JDK and needed to fire up android studio. Worked like charm

Leave a Reply

Your email address will not be published. Required fields are marked *