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.
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!
Thanks a lot Nick. All these 3 steps worked for me without any issues? I have successfully launched my java application. thanks again.
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.
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
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.
Cool!. Thanks.
Great! Tested on Java JDK 8u162 for Windows 10 Pro x64
Thanks Nick!
It worked with jdk-8u161-windows-x64.exe.
You saved me a lot of time answering stupid questions in installation requirement forms!
Nice. It worked for the lastest jdk8 available. Thanks
Nice… worked as a charm… appreciate it.
Brilliant! You just saved me! Thanks man 🙂
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
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.
You need to execute the command in the command prompt, see https://youtu.be/MBBWVgE0ewk
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 🙂
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).
I dug out some answers from superuser, I hope they’ll help you!
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 (.
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 asjdk-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!Hi Nick,
Great how-to, thanks!
I wrote down a condensed version on my own blog just to preserve it for me and to include the part about 7zip Portable: https://odoepner.wordpress.com/2016/09/15/install-portable-jdk-on-windows-without-admin-rights/
I credited you and your blog post for the steps and the unpack200 command line.
I hope that’s ok with you.
Cheers
Oliver
Awesome! Sure I’m ok 🙂
Awesome, It worked, Thanks a lot dude!
it is asking me for a user and a password in order to install 7z
Hi! Try to use a portable version of 7z.
Awesome.. worked like a charm
Thank you so much! Really cool thing!
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>
You seem to try to execute the unpack200 command in the 7-Zip directory. You need to execute it inside the unpacked Java SDK root directory.
Do you have the tools.zip file extracted there?
I can’t redistribute Oracle binaries.
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.
That is a nice improvement to the snippet, i am gonna edit the post to that, thanks!
Nice trick, thanks a lot
Thanks Nick, this helped me on Eclipse Portable. Worked like charm.
Thanks nick, this helped me on laptop where i couldnt install JDK and needed to fire up android studio. Worked like charm