> ## Content Index
> Fetch the complete content index at: https://www.ggorantala.dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# JDK Installer Says Permission Denied? Install Java Without Admin
- URL: https://www.ggorantala.dev/install-jdk-without-admin-rights/
- Published: 2026-12-02T18:33:34.000Z
- Updated: 2026-12-02T18:33:34.000Z
- Description: A JDK installer that fails with permission denied is asking for admin rights you don't need. How to install the JDK without admin rights on Windows, macOS and Linux, and the extraction mistakes that leave java itself saying Permission denied.
- Author: Gopi Gorantala
- Tags: install-jdk-without-admin, permission-denied, jdk-archive, user-environment-variables, jspawnhelper, jdk-setup, java-errors

You don't need admin rights to install a JDK. You need admin rights to run a JDK *installer*, and those are two different things.

A JDK is a folder. `bin`, `lib`, `conf`, a few others. Nothing in it has to live in `C:\Program Files` or `/usr/lib/jvm` to work, and nothing in it needs a registry key or a system service. The installers put it in a system location because that's where software for every user on the machine goes, and writing there takes admin rights. So on a locked-down laptop, the way to install the JDK without admin rights is to skip the installer, take the archive version of the same JDK, and unpack it somewhere you own.

That part takes five minutes. The interesting failures come after, when the JDK is unpacked and `java` itself says Permission denied. I'll get to those, because one of them only shows up the first time your code starts a child process.

## Four refusals, one cause

Here's what the refusal looks like on Linux, captured as an ordinary user (`dev`, no sudo) on Ubuntu 24.04 with an OpenJDK 21.0.13.1 archive:

```log
$ apt-get install -y openjdk-25-jdk
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

$ sudo -n true
sudo: a password is required

$ tar xzf jdk-21.0.13_linux-x64.tar.gz -C /usr/lib/jvm
tar: jdk-21.0.13: Cannot mkdir: Permission denied
tar: jdk-21.0.13/jmods: Cannot mkdir: No such file or directory

```

On Windows, the Oracle `.exe` and `.msi` and the Temurin `.msi` all go for `C:\Program Files`, so you get a UAC prompt asking for an administrator's credentials, and the install stops there if you don't have them. Oracle's [Windows install guide for JDK 25](https://docs.oracle.com/en/java/javase/25/install/installation-jdk-microsoft-windows-platforms.html?ref=ggorantala.dev) says it flat out: "You must have administrator privileges to install the JDK on Microsoft Windows." Adoptium's [MSI page](https://adoptium.net/installation/windows/?ref=ggorantala.dev) describes its installer as "designed for use on a per-machine basis, not per-user basis". On macOS, the `.pkg` installer writes to `/Library/Java/JavaVirtualMachines` and asks for an admin password.

Every one of these is the same refusal. Something tried to write to a folder that belongs to the system, and you're not the system.

## Is it the installer, or the folder?

Before doing anything, look at which of two situations you're in, because they need different fixes:

1. **The install step itself failed.** apt, dnf, the `.exe`, the `.msi`, the `.pkg`, or a `tar -C` into a system folder. That's this section and the per-OS fix below.
2. **The JDK is unpacked, and running it fails.** `bash: ./bin/java: Permission denied`, or `java -version` works and `ProcessBuilder` doesn't. Admin rights have nothing to do with it, and installing again in the same way won't help.

On Linux and macOS you can tell in one command whether a folder is yours to write to:

```bash
test -w /usr/lib/jvm && echo writable || echo "not yours"
test -w "$HOME" && echo writable || echo "not yours"

```

My first guess for case 2, the first time I hit it, was that I'd somehow unpacked into a folder I didn't own. I hadn't. The folder was mine, the files were mine, and the kernel still refused to run them.

## Get refused on purpose, as a normal user

The lab is a throwaway user on Linux plus the same JDK packed two ways. I ran it in a disposable container as root, then dropped to the unprivileged user. Do it in a container or VM too, since one step mounts a filesystem.

What I used: Ubuntu 24.04, OpenJDK 21.0.13.1 (Ubuntu build), packed into a `.tar.gz` and a `.zip` of the same folder, about 154 MB each.

1. Create the user and give it the archives:`bash useradd -m dev cp jdk-21.0.13_linux-x64.tar.gz jdk-21.0.13.zip /home/dev/ chown dev:dev /home/dev/jdk-21.0.13* su - dev`
2. Try the system locations. You get the three refusals from the first section.
3. Unpack into your own folder. This works:`log $ mkdir -p ~/.local/jdks && tar xzf jdk-21.0.13_linux-x64.tar.gz -C ~/.local/jdks $ ~/.local/jdks/jdk-21.0.13/bin/java -version openjdk version "21.0.13.1" 2026-11-17 OpenJDK Runtime Environment (build 21.0.13.1+2-1-24.04.1-Ubuntu) OpenJDK 64-Bit Server VM (build 21.0.13.1+2-1-24.04.1-Ubuntu, mixed mode, sharing)`
4. Now unpack the zip with a tool that ignores Unix permissions. I tried Python's `zipfile` and the JDK's own `jar xf`. Both gave the same result:`log $ ~/.local/jdks/jdk-21.0.13/bin/jar xf ../jdk-21.0.13.zip $ ls -l jdk-21.0.13/bin/java -rw-rw-r-- 1 dev dev 14456 Dec 2 11:25 jdk-21.0.13/bin/java $ ./jdk-21.0.13/bin/java -version bash: ./jdk-21.0.13/bin/java: Permission denied`
5. Do the "obvious" repair, `chmod +x bin/*`, and run a small program that starts a child process. Picture a CSV importer that calls out to `gzip` before it reads a file:`java public class Spawn { public static void main(String[] a) throws Exception { Process p = new ProcessBuilder("true").start(); // forks via lib/jspawnhelper on Linux System.out.println("exit=" + p.waitFor()); } }log $ ./bin/java -version openjdk version "21.0.13.1" 2026-11-17 $ ./bin/java ~/Spawn.java Exception in thread "main" java.io.IOException: Cannot run program "true": posix_spawn failed, error: 13 (Permission denied) Possible reasons: - Spawn helper ran into JDK version mismatch - Spawn helper ran into unexpected internal error - Spawn helper was terminated by another process Possible solutions: - Restart JVM, especially after in-place JDK updates - Check system logs for JDK-related errors - Re-install JDK to fix permission/versioning problems - Switch to legacy launch mechanism with -Djdk.lang.Process.launchMechanism=VFORK at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1170) at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1089) at Spawn.main(Spawn.java:3)chmod +x lib/jspawnhelper` and the same program prints `exit=0`.
6. Last one. As root, mount a `noexec` tmpfs at `/mnt/noexec` and make it world-writable. As `dev`, unpack the *tarball* there. The permission bits are perfect and it still fails:`log $ ls -l /mnt/noexec/jdk-21.0.13/bin/java -rwxr-xr-x 1 dev dev 14456 Dec 2 11:25 /mnt/noexec/jdk-21.0.13/bin/java $ /mnt/noexec/jdk-21.0.13/bin/java -version bash: line 1: /mnt/noexec/jdk-21.0.13/bin/java: Permission denied $ findmnt -no OPTIONS -T /mnt/noexec rw,noexec,relatime,size=614400k`

Teardown: `umount /mnt/noexec`, `userdel -r dev`, and delete the two archives. Together they're over 300 MB, and you'll forget they're there.

## Start here if you're in a hurry

Download the JDK as an archive (`.zip` on Windows, `.tar.gz` on macOS and Linux), unpack it inside your home folder, and point `JAVA_HOME` and your user `PATH` at it. No installer, no admin rights.

If `java` then says Permission denied, either the extraction dropped the execute bits or the folder sits on a filesystem mounted `noexec`.

## Where the 'Permission denied' actually comes from

The install-time refusals come from ordinary file permissions. `/usr/lib/jvm`, `/var/lib/dpkg`, `C:\Program Files` and `/Library` are writable by root or Administrators only. apt even tells you so (`are you root?`).

The run-time one is stranger. When your shell runs `./bin/java`, it calls `execve`, and the kernel returns `EACCES` (error 13, the "Permission denied" text) in two situations that matter here. The [execve(2) man page](https://man7.org/linux/man-pages/man2/execve.2.html?ref=ggorantala.dev) lists both: the file has no execute permission for you, or it sits on a filesystem mounted `noexec`. Bash prints the same words for both, which is why I wasted time on `chmod` in step 6 of the lab. The bits were fine. The mount wasn't.

Where do the missing bits come from? A zip file can carry Unix permissions; my zip stored them. But neither Python's `zipfile.extractall` nor `jar xf` puts them back, so every file came out as `rw-rw-r--`. Tarballs keep modes, which is one reason JDK vendors ship `.tar.gz` for Linux and macOS.

Then the surprise. `bin/` isn't the only place a JDK keeps executables. On Linux, `ProcessBuilder.start()` and `Runtime.exec()` don't fork your program directly. Since JDK 12 the default launch mechanism on Linux is `POSIX_SPAWN`, which spawns a small helper, `lib/jspawnhelper` ([its source](https://github.com/openjdk/jdk/blob/jdk-21%2B35/src/java.base/unix/native/jspawnhelper/jspawnhelper.c?ref=ggorantala.dev)), and the helper then runs your command. If `jspawnhelper` isn't executable, `java -version` works, your app starts, your tests that don't shell out pass, and the first `ProcessBuilder` call dies with `error: 13`. The message even lists a JDK version mismatch first among its possible reasons, which sends you hunting in the wrong direction. Fixing permissions on `bin/*` alone builds you exactly that trap.

What I checked for this one: every refusal above on Ubuntu 24.04 as an unprivileged user, two zip extractors and tar, and the `noexec` case, all against the JDK 21.0.13.1 build. The Windows and macOS steps below follow Oracle's and Adoptium's docs; I don't have either OS in this lab, so I haven't run them, and I've left out output I didn't see.

## Installing the JDK without admin rights, per OS

Get the archive from your vendor's download page, picking "zip" or "tar.gz" rather than the installer. For Temurin, the Adoptium API gives a stable URL per version, OS and CPU; the examples use it, and you can swap in Oracle, Corretto, Zulu or Microsoft archives the same way. Adoptium's [archive instructions](https://adoptium.net/installation/archives/?ref=ggorantala.dev) cover the same ground in a few lines.

### Windows

Unpack into `%LOCALAPPDATA%\Programs\Java`, which is yours and lives outside OneDrive syncing:

```powershell
$dest = "$env:LOCALAPPDATA\Programs\Java"
New-Item -ItemType Directory -Force $dest | Out-Null
Expand-Archive -Path .\OpenJDK21U-jdk_x64_windows_hotspot.zip -DestinationPath $dest
Get-ChildItem $dest   # note the folder name, e.g. jdk-21.0.x+y

```

Then set user-level variables. No admin needed, because they go under `HKCU\Environment`:

```powershell
$jdk = "$env:LOCALAPPDATA\Programs\Java\<jdk-folder>"
[Environment]::SetEnvironmentVariable('JAVA_HOME', $jdk, 'User')
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
[Environment]::SetEnvironmentVariable('Path', "$jdk\bin;$userPath", 'User')

```

Replace `<jdk-folder>` with the real name. If you'd rather click, run `rundll32.exe sysdm.cpl,EditEnvironmentVariables` and edit the top half only (your account). Avoid `setx PATH "%PATH%;..."`: it copies the merged system and user `PATH` into your user `PATH`, and it truncates values longer than 1024 characters.

Open a **new** terminal and check with `where java` and `java -version`.

One catch here confuses more people than the install does. Windows builds a process `PATH` as the system `PATH` followed by the user `PATH`. If an admin already installed some Java machine-wide, or the Oracle installer left `C:\Program Files\Common Files\Oracle\Java\javapath` in the system `PATH`, that one wins over yours. You can't remove it without admin rights, but tools that read `JAVA_HOME` (Maven, Gradle, most IDEs) will use your JDK anyway. For the terminal, put `%JAVA_HOME%\bin` first in the session, or read [why the wrong Java version runs](https://ggorantala.dev/wrong-java-version-path-order/?ref=ggorantala.dev).

If your company uses AppLocker or a similar allow-list, executables under your profile may be blocked outright. That's a policy decision, not a permissions bug, and the honest fix is a ticket.

### macOS

macOS already has a per-user JDK folder: `~/Library/Java/JavaVirtualMachines`. `/usr/libexec/java_home` searches it alongside `/Library/Java/JavaVirtualMachines`, so a JDK unpacked there gets picked up like an installed one.

```bash
mkdir -p ~/Library/Java/JavaVirtualMachines
cd ~/Library/Java/JavaVirtualMachines
curl -L -o jdk21.tar.gz \
  "https://api.adoptium.net/v3/binary/latest/21/ga/mac/aarch64/jdk/hotspot/normal/eclipse"
tar xzf jdk21.tar.gz && rm jdk21.tar.gz
/usr/libexec/java_home -V

```

Use `x64` instead of `aarch64` on an Intel Mac. The archive unpacks to `jdk-21.x.y+z/Contents/Home`, and `Contents/Home` is the real JDK root. Then, in `~/.zshrc`:

```bash
export JAVA_HOME="$(/usr/libexec/java_home -v 21)"
export PATH="$JAVA_HOME/bin:$PATH"

```

Downloading with `curl` matters a little. Browsers tag downloads with the quarantine attribute, and Gatekeeper may then complain about the unpacked binaries. `curl` doesn't add it.

### Linux

Tarball into your home folder, then your shell profile:

```bash
mkdir -p ~/.local/jdks
curl -L -o /tmp/jdk21.tar.gz \
  "https://api.adoptium.net/v3/binary/latest/21/ga/linux/x64/jdk/hotspot/normal/eclipse"
tar xzf /tmp/jdk21.tar.gz -C ~/.local/jdks && rm /tmp/jdk21.tar.gz
ls ~/.local/jdks

```

```bash
# ~/.bashrc (or ~/.zshrc)
export JAVA_HOME="$HOME/.local/jdks/<jdk-folder>"
export PATH="$JAVA_HOME/bin:$PATH"

```

If you'd rather not manage folders by hand, SDKMAN installs into `~/.sdkman` and never asks for sudo; [switching between several JDKs](https://ggorantala.dev/switch-java-versions-multiple-jdks/?ref=ggorantala.dev) covers it.

### When java itself says Permission denied

Check the mount first, since `chmod` can't fix it:

```bash
findmnt -no OPTIONS -T ~/.local/jdks | tr ',' '\n' | grep -x noexec

```

Any output means `noexec`. Move the JDK to a folder on a filesystem that allows execution; you can't remount without root.

Otherwise, restore execute bits on **both** places that need them, not only `bin`:

```bash
cd ~/.local/jdks/<jdk-folder>
chmod +x bin/* lib/jspawnhelper
find . -type f -name '*.so' ! -perm -u+r -print   # should print nothing

```

Better still, delete the folder and unpack the `.tar.gz` with `tar`, which keeps the modes the vendor set. If all you have is a zip on Linux, `unzip` (Info-ZIP) restores stored Unix modes; `jar xf` and Python's `zipfile` don't.

## Keep JDKs in your home folder on purpose

Even on machines where I do have admin rights, I've stopped putting development JDKs in system folders. A JDK unpacked under your home folder is one directory you can delete, replace or keep three versions of side by side, and no package manager or vendor updater changes it behind your back. The installer buys you a Start-menu entry and a `PATH` edit. You can do the `PATH` edit yourself.

What I keep: one folder for JDKs (`~/.local/jdks`, `~/Library/Java/JavaVirtualMachines` or `%LOCALAPPDATA%\Programs\Java`), archives fetched with `curl` or the vendor's zip, `JAVA_HOME` set in exactly one place (the [JAVA\_HOME guide](https://ggorantala.dev/set-java-home-windows-macos-linux/?ref=ggorantala.dev) has the per-OS spots), and builds that pin their own JDK through Maven or Gradle toolchains so the laptop's default barely matters.

## The test that would have caught this

`java -version` proves the launcher runs. It doesn't prove the JDK is whole. After unpacking, run something that also exercises the compiler and the spawn helper:

```bash
cat > /tmp/Check.java <<'EOF'
public class Check {
    public static void main(String[] a) throws Exception {
        int rc = new ProcessBuilder("java", "-version").inheritIO().start().waitFor();
        System.out.println("child exit=" + rc + ", java.home=" + System.getProperty("java.home"));
    }
}
EOF
javac -d /tmp /tmp/Check.java && java -cp /tmp Check

```

If that prints `child exit=0` and a `java.home` inside your folder, the install is good. This behaves the same on JDK 17, 21 and 25; the long "Possible reasons" text under a spawn failure is newer than the failure itself, so older 17 and 21 builds print a shorter message for the same problem. When you upgrade, unpack the new version into a new folder and repoint `JAVA_HOME`, rather than unpacking over the old one. If a [JDK folder does get damaged](https://ggorantala.dev/repair-corrupted-jdk-installation/?ref=ggorantala.dev), replace the folder.

## Screenshot this bit

- The installers need admin rights. The JDK doesn't. Use the zip or tar.gz and unpack it into your home folder.
- On Windows, set `JAVA_HOME` and `PATH` at user level; a machine-wide Java in the system `PATH` still wins in terminals.
- `bash: ./bin/java: Permission denied` on a folder you own means lost execute bits or a `noexec` mount. Check the mount before you `chmod`.
- `chmod +x bin/*` isn't enough. `lib/jspawnhelper` needs it too, or `ProcessBuilder` fails with `error: 13`.
- Unpack tarballs with `tar`, never with `jar xf`.

## Things people ask before emailing IT

### How do I install Java without admin rights on Windows?

Download the JDK `.zip` instead of the `.exe` or `.msi`, unpack it into `%LOCALAPPDATA%\Programs\Java`, and set `JAVA_HOME` and `Path` as user variables, which don't need admin rights. Open a new terminal afterwards. A Java that's already in the system `PATH` will still come first there, but tools that read `JAVA_HOME` will use yours.

### Can I install the JDK on a Mac without an admin password?

Yes. Unpack the `.tar.gz` into `~/Library/Java/JavaVirtualMachines`, which `/usr/libexec/java_home` searches next to the system folder, then set `JAVA_HOME` with `java_home -v`. Only the `.pkg` installer needs the admin password.

### Why does java say Permission denied after I extracted it?

Either the extraction tool dropped the execute bits, which `jar xf` and Python's `zipfile` both do, or the folder is on a filesystem mounted `noexec`. Run `findmnt -no OPTIONS -T` on the folder; if `noexec` is there, move the JDK. If not, re-extract the `.tar.gz` with `tar`, or `chmod +x bin/* lib/jspawnhelper`.

### Is a JDK from a zip file different from an installed one?

Not in any way your code can see. It's the same build, without registry entries, Start-menu shortcuts, file associations or automatic `PATH` edits. Updates are manual: unpack the new version alongside and repoint `JAVA_HOME`.