Skip to content

How to run java code in a restricted sandbox (without network, filesystem access)

Say some programmer gives me an executable jar (from Java code) along with the entry point to use. I want to run this jar (programmatically) from Java code in a restricted sandbox environment with no network or filesystem access or database access and a fixed amount of CPU and memory. I.e., the Java code should not cause any side effects on other programs running on the my jvm.

Ideally I would like to allow certain access based on situation (say for example, only files in a certain directory with quota).



You can control the environment using policy files (archived version

you could run then run your jar

java -jar

User contributions licensed under: CC BY-SA
9 People found this is helpful