I just started using Java ScriptEngine to make small extensions for my application, then I noticed that I can import all java classes into a script and use them without restrictions. Is there a way to indicate which classes a script can use? I donโt want them to do things likejava.lang.System.exit(1);
java.lang.System.exit(1);
Well, you seem to need to learn about the Java SecurityManager. This is a pretty big topic, you can read it, and then post a more specific question if you have problems with its work.
Java. .
I solved this by putting "importPackage = null" on top of all the scripts, it seems to work, but I'm not sure that this hack can be avoided.