The Java Security Manager was a mechanism that restricted what Java code could do at runtime, such as reading files, opening sockets or reading system properties, based on a policy file. It is now obsolete: it was deprecated for removal in Java 17 (JEP 411) and permanently disabled in Java 24 (JEP 486), so new applications cannot use it.
This article explains how it worked, why it was retired, and what to use for isolation and sandboxing today.
The java.lang.SecurityManager class was consulted by the JDK before sensitive operations. The JDK libraries called methods such as checkRead, checkConnect or checkExit, which in practice delegated to the access controller. If the calling code had not been granted the matching Permission, a SecurityException was thrown.
It was designed for the era of Java applets and Java Web Start, where untrusted code downloaded from the web had to be confined in a sandbox. Permissions were granted to code by origin and signer through a policy file.
You enabled it on the command line and pointed the JVM to a policy file.
A policy file grants permissions to code sources:
Code could also install a manager programmatically with System.setSecurityManager(...) and run privileged code blocks with AccessController.doPrivileged. All of these APIs are deprecated for removal.
JEP 411 summarised the reasons:
The timeline is short:
| Release | Change |
|---|---|
| Java 17 | Security Manager deprecated for removal (JEP 411); enabling it prints a warning |
| Java 18 to 23 | The manager must be enabled explicitly with -Djava.security.manager=allow to be installed at runtime |
| Java 24 | Permanently disabled (JEP 486); the APIs remain but no manager can be installed |
In Java 24 and later, System.getSecurityManager() returns null, and System.setSecurityManager(...) throws UnsupportedOperationException. Starting the JVM with -Djava.security.manager causes a startup error unless the value is disallow. Code that merely checks System.getSecurityManager() != null still compiles and simply takes the no-manager path.
For untrusted or multi-tenant workloads, isolate outside the JVM:
For application-level hardening, the JVM still helps through strong encapsulation of the module system, signed JARs, --enable-native-access for native code, and serialization filters (ObjectInputFilter) to block dangerous deserialization.
-Djava.security.manager and policy files from launch scripts.doPrivileged blocks with plain calls once no manager is installed.System.exit from a plugin and used a manager to block it, move the plugin into its own process.System.exit; use process isolation or their updated alternatives.No, not in practice. The classes still exist for compatibility, but since Java 24 the JVM does not allow a Security Manager to be installed.
It removes a feature that few used. Java still enforces memory safety, bytecode verification and module encapsulation, and real isolation is better handled by the operating system or containers.
Yes, on those releases it works as before, but they are older versions and you should plan migration to a current LTS such as Java 21 or 25.
Run it in a separate, locked-down process or container with minimal permissions, and communicate through a narrow API.
The Security Manager was Java's policy-based sandbox for untrusted code, built around permissions and policy files. It was deprecated in Java 17 and disabled in Java 24, so rely on containers, operating system sandboxing and process isolation instead, and remove manager-related flags and doPrivileged code during migration.