Installing JDK without administrator privileges

前端 未结 14 1650
旧时难觅i
旧时难觅i 2020-12-13 00:13

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 Dev

相关标签:
14条回答
  • 2020-12-13 00:39

    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
    0 讨论(0)
  • 2020-12-13 00:41

    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.

    0 讨论(0)
  • 2020-12-13 00:43

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

    0 讨论(0)
  • 2020-12-13 00:46

    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:

    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.

    0 讨论(0)
  • 2020-12-13 00:47

    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.

    0 讨论(0)
  • 2020-12-13 00:48

    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.

    0 讨论(0)
提交回复
热议问题