Installing JDK without administrator privileges
Asked Answered
A

14

49

I am trying to install JDK at office laptop but it says I need administrator privileges. I have only access to my own account at work.

How can I install the Java Development Kit without administrator rights?

Abigail answered 5/6, 2012 at 4:4 Comment(4)
your office probably has some sort of elevated privileges so you can install software, ask you manager or sys adminIce
Believe me, sometimes it is not as simple... In my previous company I had to fill a form to justify my needs and then wait one month...Deshabille
Yes, actually I have to fill out bunch of forms online. But I don't have access to the online website from home. I have to install it tonight though.Abigail
There is an identical question over on Super User. Please see that question and its answers. I believe that my recent late answer there might solve your problem. But first please see Joe Taylor's comment on the question.Langan
I
25

Here is a workaround to install java without admin privileges or without administrator password. For this you need cygwin installed which does not require admin privileges. In the utils make sure you select cabextract.exe to install it.

Fireup cygwin bash shell.

Type cabextract jdk1.6.exe <-- jdk file name

this will extract all the files into the current directory.

Move tools.zip to a new directory and unzip it using cygwin or windows explorer. This will be your java directory.

Hint: Try to subsitite 7zip instead of cabextract and cygwin. If it works it will be much faster.

Edit: This doesn't get you a working JDK with the latest versions of jdk 6 and 7. Many of the jar files (eg rt.jar) are compressed so they need to be decompressed using unpack200.

Just go through each directory looking for files with a .pack extension and unpack them using unpack200, eg: .\jre\bin\unpack200 .\jre\lib\rt.pack .\jre\lib\rt.jar

This allows you to run java programs however I still had trouble with Eclipse as there was some issue with annotations, so there's probably another step that is missing.

In the answers to this similar question on Superuser is available a script that automatically finds all .pack files and unpacks them in the right folders.

Inspection answered 13/11, 2012 at 4:52 Comment(3)
7zip only partially extracted the cab file. It got jre.msi (which it was also able to extract) but not the jdk part of the cab file.Snail
If you have cygwin, to find the .pack files $ find . -name *.packBruin
This didn't work for me with JDK7u71 on Windows 7. But the answer below about 'Server JRE' did work.Semipermeable
F
54

Starting with Java SE 7u21, Oracle offers a so-called Server JRE for download. This is a standard .tar.gz archive that you can extract anywhere on your computer. Although the download is called JRE, it contains a "normal" JDK subdirectory (including the javac compiler etc.).

Instructions:

  • download the "Server JRE" from Java download site
  • extract the .tar.gz
  • add the bin subdirectory to your PATH
Frontispiece answered 13/6, 2014 at 11:38 Comment(10)
The JRE != The JDK; it's lacking a compiler, etc.Adalai
@Adalai Did you actually check the download? It's a complete JDK.Frontispiece
I stand corrected: this does contain a javac binary, it seems, despite being a full 100MB lighter than the JDK. I haven't verified if it all functions as intended or not, though.Adalai
Unfortunately the Server JRE is not available for Mac.Triggerhappy
great. although it is missing 32-bit windows version. which isn't surprising for "server" version, but sometimes still needed for a desktop pc.Abingdon
The JDK is not complete. JAVAFX is absent, as an example!Plenty
As already mentionned, it works on windows, it has a compiler, but has no jFXWebkit.dll, no sources.zip, and may not work for ui (since it is intended for server only). Still a nice workaround.Cytotaxonomy
Well, adding to the PATH imposes a problem if you don't have Admin rights... :/Attenweiler
@Attenweiler Why? On Windows, you can edit the environment variables for your user account (instead of the system-wide ones) without Admin privileges, and on Linux/Unix, you can just set your $PATH variable accordingly (e.g. in your .bashrc)Frontispiece
Doesn't work for me. The package contains a directory called jdk, but my IDE (IntelliJ) doesn't accept it as a JDK folder.Blowpipe
E
31

Oracle changed the package format in update 102 as pointed by @Webrjn on a previous answer at this question, but the unpack method still works with two more unzip actions:

enter image description here

  1. The installation executable of the JDK is a zipped file, so just unzip it with 7z to any folder you want.
  2. Go to the directory .rsrc/1033/JAVA_CAB10/.
  3. The only file there is 111, which is also a zipped file containing tools.zip. Unzip it to get tools.zip.
  4. So now perform the original unpack process, by unzipping tools.zip to your desired java installation path.
  5. Open a windows command prompt and run:

    for /r %i in (*.pack) do .\bin\unpack200.exe -r -v %i %~pi%~ni.jar
    

    The unpack200 program complains about garbage at the end of the files, but the unpacked jars are tested ok by 7z.

  6. Java source src.zip is within the file 110 located inside .rsrc/1033/JAVA_CAB9.

By the way, update 101 only contains the tools.zip file and can be installed with the previous unpack method.

Eighteen answered 21/7, 2016 at 18:24 Comment(9)
"Java source src.zip is the file 110 at .rsrc/1033/JAVA_CAB9": that gives me (with 8u102) a javafx-src.zip of only 5 MB, as opposed to a regular src.zip found in jdk-8u102-linux-x64.tar.gz (21 MB)Bhatt
You are talking about different files, javafx-src.zip is the source for JavaFx only classes while src.zip is the source for Java classes. javafx-src.zip size is 4972 KB.Eighteen
I agree. My point was: I am only interested in src.zip, and I don't think src.zip is present in one of those CAB files. I always have to extract it from the Linux package.Bhatt
In Windows .exe, it is present at .rsrc\1033\JAVA_CAB9\110, while in Linux tgz it is at the root. Just unzip file 110Eighteen
That is what I did (unzip 110) and... it gave me javafx-src.zip, not src.zipBhatt
Sorry, I coundn´t reproduce it. I just downloaded jdk-8u102-windows-x64.exe from Oracle.com, unziped .rsrc\1033\JAVA_CAB9\110 as discussed above and got src.zip with a size of 20755 KB.Eighteen
Since this is the most current and correct work-around, this should be stickied to the top even if it's not the selected answer according to OP.Piercy
Has saved my dinosaur-driven, process-lacking workspace several times already... Thank you, manDeplume
Note that step 5 as it is currently written will fail if you have spaces in your path to the tools folder.Norge
I
25

Here is a workaround to install java without admin privileges or without administrator password. For this you need cygwin installed which does not require admin privileges. In the utils make sure you select cabextract.exe to install it.

Fireup cygwin bash shell.

Type cabextract jdk1.6.exe <-- jdk file name

this will extract all the files into the current directory.

Move tools.zip to a new directory and unzip it using cygwin or windows explorer. This will be your java directory.

Hint: Try to subsitite 7zip instead of cabextract and cygwin. If it works it will be much faster.

Edit: This doesn't get you a working JDK with the latest versions of jdk 6 and 7. Many of the jar files (eg rt.jar) are compressed so they need to be decompressed using unpack200.

Just go through each directory looking for files with a .pack extension and unpack them using unpack200, eg: .\jre\bin\unpack200 .\jre\lib\rt.pack .\jre\lib\rt.jar

This allows you to run java programs however I still had trouble with Eclipse as there was some issue with annotations, so there's probably another step that is missing.

In the answers to this similar question on Superuser is available a script that automatically finds all .pack files and unpacks them in the right folders.

Inspection answered 13/11, 2012 at 4:52 Comment(3)
7zip only partially extracted the cab file. It got jre.msi (which it was also able to extract) but not the jdk part of the cab file.Snail
If you have cygwin, to find the .pack files $ find . -name *.packBruin
This didn't work for me with JDK7u71 on Windows 7. But the answer below about 'Server JRE' did work.Semipermeable
S
15

Here are all the steps that got the JDK installed on Windows 7 without admin rights.

  1. You need the cabextract program to extract the installer files. I tried 7zip but it didn't extract the cab properly. Instead, I used cygwin. You can get the setup.exe program from their website, but you must rename it because Windows assumes that anything called "setup" requires admin rights. I renamed it to cygwin.exe. Run that. It'll ask you where to install. I chose the cygwin directory in my home directory. When the pop-up asks you which programs to install, type "cabinstall" in the search bar. Expand the "Archive" section and make sure the "cabinstall" is not set to "skip". (Click the "skip" text until the highest number shows.) Proceed with install. This takes a few minutes.

  2. Optional: Add cygwin\bin to your path. Do this from control panel, user accounts, change my environment variables, edit PATH.

  3. Download the JDK. I downloaded jdk-6u45-windows-x64.exe.

  4. In the directory where that file is: mkdir tmp

  5. cd tmp

  6. cabextract ..\jdk-6u45-windows-x64.exe

  7. Make a new directory for the actual JDK. I used jdk in my home directory.

  8. Extract the tools.zip file into that. It comes with the Java runtime, so you don't need the other files in the original cab, such as jre.msi.

  9. Unpack all the .pack files. You can do that manually by running the bin/unpack200 program on them, or use bash (if you installed cygwin above):

    1. bash

    2. for f in $(../cygwin/bin/find . -name "*.pack"); do bin/unpack200 $f ${f%.*}.jar; done

  10. Add jdk/bin to your PATH (see step 2 above).

Snail answered 18/6, 2013 at 6:6 Comment(1)
Note: You may have to run the cygwin setup program with the -B option if you do not have admin rights.Autodidact
H
6
  1. Download the JDK
  2. Extract it by using 7 ZIP (Extract the exe file) enter image description here

It contains a single file tools.zip, which contains all the files we need. 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 windows inside the JDK directory (e.g. “D:\JavaJDK\”):

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

Regard that you will have to adjust the path of the unpack200 binary (“D:\JavaJDK\bin\unpack200”) to your chosen directory.

  1. Congrats you now have a working, portable JDK! enter image description here

Reference: this link

Hornstone answered 25/3, 2016 at 13:27 Comment(2)
Thank you, the only working way without installing external program.Iridis
Nevertheless, this method lacks src.zip so I had to follow Leonardo Vidal's answer to get this file and have a full JDK.Iridis
D
4

I guess you are on Windows. You cannot install the JDK provided by Oracle without administrator right. What you can do is installing it on an other machine (or find a machine where it is installed) and copy the jdk dir.

Deshabille answered 5/6, 2012 at 4:9 Comment(1)
Yes it is Windows. Okay so I will install it in another machine and then try transferring it to office laptop. Thanks.Abigail
L
3

jdk-8u102-windows-x64.exe no longer works with the unpack method, Oracle seem to have changed the package format.

enter image description here

Laudian answered 20/7, 2016 at 8:50 Comment(1)
This answers my question, I was wondering how all the other answers did itAristaeus
T
2

If you can install it on any other machine then this solution will help you.

  • Install it on another machine.
  • Bring the jdk folder on your machine and set system and classpath variable to the path where you have copied the jdk folder. You should be able to run your programs.
Townley answered 5/6, 2012 at 4:16 Comment(2)
'Rohan Durve' has mentioned one alternate, if you don't have any other machine, install it in USB and later copy it in your system.Townley
Hmms so you are saying I transfer it through USB from another laptop to office laptop. Will that work? I ll try it. Thanks.Abigail
F
2

Maybe a good alternative is to use OpenJDK, here is an unnoficial build for windows, so you can download the Zip file extract to any folder and set the JAVA_HOME for your windows user. I ran Android Studio this way.

Foretop answered 30/7, 2014 at 20:36 Comment(0)
H
2

In order to easily install Java JDK on Windows without administrator privileges, you can use https://aws.amazon.com/corretto/. It contains a portable amazon-corretto-<version>-windows-x64-jdk.zip file, that you just need to download and unzip.

  1. Download the portable zip file from amazon.com, e.g. https://d3pxv6yz143wms.cloudfront.net/8.232.09.1/amazon-corretto-8.232.09.1-windows-x64-jdk.zip

  2. Unzip it in a folder, e.g. C:\Users\John\programs

  3. Set the JAVA_HOME variable, e.g. set JAVA_HOME=C:\Users\John\programs\jdk1.8.0_232

  4. Add the path to the "bin" folder to the PATH: e.g. set PATH = %PATH%; %JAVA_HOME%\bin

  5. Test if the installation works with javac -version

Remark #1. I am proposing this alternative technique using Amazon Corretto because other proposed answers requires 7-zip for which you need administrative rights to install, and I did not find a simple portable .zip version of 7-zip.

Remark #2. You can set up your environment by having a my-cmd.cmd file which contains the needed variables:

rem # PROMPT is an optional question of taste ;-)
prompt [$P]$_$$$S
rem # VARIABLE(S)
set JAVA_HOME=C:\Users\UW31RY\programs\jdk1.8.0_232
rem # PATH
set PATH=C:\WINDOWS;C:\WINDOWS\system32;%JAVA_HOME%\bin
rem # Clear the screen!
cls

and creating a shortcut with %windir%\system32\cmd.exe /K "my-cmd.cmd" as Target: value, and the folder which contains the my-cmd.cmd file as Start in: value, e.g. C:\Users\John\work.

Hedvige answered 12/12, 2019 at 13:52 Comment(0)
C
1

http://www.ehow.com/how_6012601_install-java-admin-privileges.html

Here you go man, Good luck. This worked for me.

Instructions on above link

1 Insert your portable USB drive into your home computer's USB slot.

2 On your home computer, navigate to the "Download Java JDK" link in the resources section.

3 Click the red "Download" button. When asked to log-in, click "Skip this step." Click "Save file" to download the file to your computer.

4 Double-click the ".exe" file you downloaded to begin the installation wizard for Java SE 6. Click "Accept" to the License Agreement.

5 On the Custom Setup page, click the small hard-drive buttons next to "Source Code," "Public JRE," and "Java DB" and for each select "Don't install this feature now."

6 Click the "Change..." button on the bottom right corner, then from the drop down menu, under "Look in:" select your portable usb drive. Click "Create New Folder" button in the in the top right corner (the folder icon), and name the new folder "JDK". Select the JDK folder and click "OK."

7 Click "Next" and wait while Java installs.

8 Open Notepad by going to "Start," "Programs," "Accessories" "Notepad."

9 In Notepad, copy-paste the following two-line batch script: set Path=%~d0\JDK\bin;%PATH% cmd

10 Click "File," "Save as," navigate to your USB drive root directory, and type "RunMeForJava.bat" as the name of your file and click "Save."

11 Insert your USB drive into the computer where you do not have Administrator privileges and double-click the ".bat" file in your USB root directory. A Command Prompt window will open. Type "javac" (without the quotes) to see that Java works and is fully installed.

Consolute answered 5/6, 2012 at 4:14 Comment(0)
M
1

The method presented by Lawrence works but you can also use 7-zip and git bash to do the whole thing without much trouble.

NOTE: git bash comes with some gnu utils and unpack200 is one of them.

There is another small thing to do though. The src.zip file which comes with JDK is not present after the unpacking so to do that you can download the Linux tar.gz version and unpack it twice with 7-zip and then copy the missing src.zip file to the windows unpacked JDK.

Not having the src.zip is not a big deal but it will provide you easy access to some JDK sources in tools like Intellij IDEA.

Milled answered 30/7, 2014 at 8:50 Comment(0)
A
0

Nice work by @Lawrence by using Cygwin. Let me show you similar steps without using any external tools.

Installing using utilities at the system without admin rights:

This works on Windows 7 or later on a system without admin rights

  1. Download the latest version of JDK: You can find it here http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. Use 7zip tool to extract the executable into a directory. Again extract the inside tools.zip file within.
  3. Goto ..\jre\bin Use SHIFT and Right Click and open Command Prompt.
  4. Type unpack200 SRC DST. Inplace of SRC: Search *.pack files within the extracted directory, copy paste the directory location of .pack files, Inplace of DST: Use the same path of .pack files, and replace the filename with .jar
  5. Do this for all the .pack files available in the directory. (Some 6-8 files are there for JDK8u65)
  6. Launch Eclipse, choose a project, click Alt+Enter, click on Build Path
  7. Goto Libraries, remove available system JRE if any. Click on Add Library, choose JRE System Library then NEXT, Click Alternate JRE , click on Installed JREs. Click Add, Standard VM then NEXT, choose Directory.
  8. Now choose the directory location of the extracted JDK you performed in step 2, then click FINISH, APPLY then OK

You must be good to go to run the project without actually installing JDK. Cheers!

Astrosphere answered 14/1, 2016 at 9:43 Comment(0)
C
0

I have tried several ways of installation, but there is a common problem:

In the worst case, if any installation requires admin privilege, then you will not be able to use 7zip because there is no portable version of 7zip. But, in Windows 10 and later versions of Windows 7(if my memory serves me well), extracting zip file is possible without any program installation: just open the .zip file with "Windows explorer" and extract them. However, this only works a normal zip file, not with JDK installer.

So, I have tried another way and it works(for oracle jdk 1.8-191): you can install a JDK in other PC where you have privilege, pass it to your company PC, and set it as the JDK to use.

  1. just intall the JDK in another PC where you have admin privilege, such as that you have at home
  2. Zip that JAVA_HOME folder(the parent folder of bin), copy it to a USB driver, and take that to your company.
  3. Unzip in a folder where you have full access, like C:\Users\<your_name>\java(because some company also restrict pasting into Program Files or somewhere else, but will never restrict what you do in your personal user folder
  4. Set JAVA_HOME variable to there(if you are not allowed to do that, just skip). The same applies to setting up the java path(adding bin\java to PATH variable)
  5. Open Intellij IDEA or Eclipse, setup your new JDK in the IDE to point to there.
  6. Write a simple Hello World program to verify.

I found this because when I look into the JDK installer, I see very similar structure as in JDK folder. So I suspect the installation only consists of extracting the content into a foler, plus some config, which we can do manually. Looks like that my theory is proved.

Coleen answered 24/9, 2019 at 12:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.