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.


Listen to some relaxing music while reading my blog post


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\”):

1
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

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

  1. Thanks a lot Nick. All these 3 steps worked for me without any issues? I have successfully launched my java application. thanks again.

  2. Ahh, sorry to spam you.

    Please find fixed Version:

    @ECHO OFF
    Setlocal EnableDelayedExpansion
    @REM See: https://www.whitebyte.info/programming/java/how-to-install-a-portable-jdk-in-windows-without-admin-rights
    @REM unpacker script for Java Windows Installer .exe tools.jar content to unpack .pack files to .jar files.
    @REM adapted by Frank Schulte, 06.12.2018

    SET JAVA_HOME=C:\Users\frank.schulte\Documents\_env\Java\jdk-1.8.192

    cls

    ver

    @ECHO.
    @ECHO Set JAVA_HOME to the path where you unpacked the tools.jar into.
    @ECHO This can be the final JAVA_HOME in case you do it there.
    @ECHO.
    @ECHO SET JAVA_HOME=%JAVA_HOME%

    @ECHO ON

    FOR /R %JAVA_HOME% %%F IN (*.pack) DO %JAVA_HOME%\bin\unpack200 -r -v -l “” “%%F” “%%~dF%%~pF%%~nF.jar”

    @ECHO OFF
    @ECHO.
    @ECHO DONE.

  3. Secound time. I did not check if the %% was rightly pasted into the comment. Please use below:

    I needed to do:

    SET JAVA_HOME=C:\_env\Java\jdk-1.8.192

    FOR /R %JAVA_HOME% %%F IN (*.pack) DO %JAVA_HOME%\bin\unpack200 -r -v -l “” “%%F” “%%~dF%%~pF.jar”

    Please note the %% used in the Expansion part. If not like this the FOR command complains.

    Cheers
    Frank

  4. Hi there,
    today I installed jdk-1.8.192 from the Oracle download .exe and I had to adapt the unpack200 step. Please find the script I used to unpack the .pack files. I was running on Windows 10 and it complained about Expansion Problems for the filename.

    Thanks for the Infos! Did save some Trouble for me!
    Greetings
    Frank

    cmd.exe
    ver

    Microsoft Windows [Version 10.0.17134.407]

    Script:

    Setlocal EnableDelayedExpansion
    @ECHO ON

    @REM Set JAVA_HOME to the path where you unpacked the tools.jar into.
    @REM This can be the final JAVA_HOME in case you do it there.
    SET JAVA_HOME=C:\Users\frank.schulte\Documents\_env\Java\jdk-1.8.192

    @REM See: https://www.whitebyte.info/programming/java/how-to-install-a-portable-jdk-in-windows-without-admin-rights
    @REM Java exe .pack unpacker script
    @REM Frank Schulte, 06.12.2018

    @REM cd %JAVA_HOME%

    FOR /R %JAVA_HOME% %%F IN (*.pack) DO %JAVA_HOME%\bin\unpack200 -r -v -l "" "%%F" "%%~dF%%~pF.jar"

    echo DONE.

  5. Thanks Nick!
    It worked with jdk-8u161-windows-x64.exe.
    You saved me a lot of time answering stupid questions in installation requirement forms!

  6. Hello,

    I’ve tried this. I’m on the last step. C:\JavaJDK\bin\unpack200 -r -v -l “” “%f” “%~pf%~nf.jar

    “Unpacking from %f to %~pf%~nf.jar
    Error: Could not open input file: %f”

    Please help

  7. I am having trouble with the last step. I fail to understand what I have to do. Can you please break it down for me?
    Thank you.

  8. 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 🙂

  9. 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 (.

  10. 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!

  11. 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>

  12. 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.

  13. 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 to Sergey Sharov Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.