# Unable to run Java in sandbox in macOS

**URL:** <https://forum.cursor.com/t/unable-to-run-java-in-sandbox-in-macos/152229>\
**Category:** Bug Reports\
**Tags:** java, sandbox, macos\
**Created:** [February 18, 2026, 10:55pm UTC](https://forum.cursor.com/t/unable-to-run-java-in-sandbox-in-macos/152229 "2026-02-18T22:55:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mzs](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@mzs](https://forum.cursor.com/u/mzs)\
**Post date:** [February 18, 2026, 10:55pm UTC](https://forum.cursor.com/t/unable-to-run-java-in-sandbox-in-macos/152229/1 "2026-02-18T22:55:03Z")

</div>

### Where does the bug appear (feature/product)?

Cursor IDE

### Describe the Bug

Java doesn’t seem to work inside the sandbox. Something about how /usr/bin/java enumerates the available JDKs is being blocked.

In the sandbox, both `java -version` and `/usr/libexec/java_home -V` give:

```auto
The operation couldn't be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

```

Outside the sandbox, `/usr/lib/java_home -V` lists the JVMs:

```auto
Matching Java Virtual Machines (3):
    25.0.1 (arm64) "Eclipse Adoptium" - "OpenJDK 25.0.1" /Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home
    21.0.5 (arm64) "Eclipse Adoptium" - "OpenJDK 21.0.5" /Users/me/Library/Java/JavaVirtualMachines/temurin-21.0.5/Contents/Home
    17.0.5 (arm64) "Eclipse Adoptium" - "OpenJDK 17.0.5" /Users/me/Library/Java/JavaVirtualMachines/temurin-17.0.5/Contents/Home
/Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home

```

If I actually symlink the `bin/java` binary from one of those into my workspace and tell the agent to run it in the sandbox, it works.

```auto
./runjava25

openjdk version "25.0.1" 2025-10-21 LTS
OpenJDK Runtime Environment Temurin-25.0.1+8 (build 25.0.1+8-LTS)
OpenJDK 64-Bit Server VM Temurin-25.0.1+8 (build 25.0.1+8-LTS, mixed mode, sharing)

```

### Steps to Reproduce

Ask the agent to run `java -version` inside the sandbox

### Operating System

MacOS

### Version Information

Version: 2.5.17 (Universal)  
VSCode Version: 1.105.1  
Commit: 7b98dcb824ea96c9c62362a5e80dbf0d1aae4770  
Date: 2026-02-17T05:58:33.110Z  
Build Type: Stable  
Release Track: Default  
Electron: 39.3.0  
Chromium: 142.0.7444.265  
Node.js: 22.21.1  
V8: 14.2.231.22-electron.0  
OS: Darwin arm64 24.6.0

### For AI issues: which model did you use?

Auto

### Does this stop you from using Cursor

No - Cursor works, but with this issue

---

<div class="post-metadata">

**Author:** ![mzs](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@mzs](https://forum.cursor.com/u/mzs)\
**Post date:** [February 19, 2026, 12:33am UTC](https://forum.cursor.com/t/unable-to-run-java-in-sandbox-in-macos/152229/3 "2026-02-19T00:33:20Z")

</div>

Oddly if I run the IDE from my terminal and set an explicit JAVA\_HOME variable, `java -version` works inside the sandbox.

`JAVA_HOME=/Users/me/Library/Java/JavaVirtualMachines/temurin-21.0.5/Contents/Home cursor .`

---

<div class="post-metadata">

**Author:** ![deanrie](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/deanrie/32/1263_2.png) [@deanrie](https://forum.cursor.com/u/deanrie)\
**Post date:** [February 19, 2026, 7:09am UTC](https://forum.cursor.com/t/unable-to-run-java-in-sandbox-in-macos/152229/4 "2026-02-19T07:09:22Z")

</div>

Hey, thanks for the detailed report.

This looks like a macOS sandbox limitation. `/usr/libexec/java_home` uses specific system paths for JDK discovery, and the sandbox blocks access to them. Glad you found a workaround with `JAVA_HOME`.

A few options:

1. Set a permanent `JAVA_HOME`. Add this to `~/.zshrc` or `~/.bash_profile`:

```bash
export JAVA_HOME=/Users/me/Library/Java/JavaVirtualMachines/temurin-21.0.5/Contents/Home

```

Then restart your terminal and open Cursor via `cursor .` so the sandbox inherits the variable.

1. Symlink inside the workspace (like you already did). If you need different versions per project, you can add a symlink in the project root and point the agent to `./runjava25` instead of `java`.

2. Legacy Terminal Tool. Try switching to the legacy terminal (Cursor Settings \> Agents \> Legacy Terminal Tool). The sandbox works differently there and might not block `java_home`.

Let me know if the workaround doesn’t fit your setup or if you want help configuring it.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [March 13, 2026, 7:10am UTC](https://forum.cursor.com/t/unable-to-run-java-in-sandbox-in-macos/152229/5 "2026-03-13T07:10:00Z")

</div>

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.
