I'm a little confused. Based off of your title I think you want to prevent users from importing classes inside JavaScript. In that case this question has already been asked here,
security problem with Java ScriptEngine.
Some of the solutions suggested there were to look into Java SecurityManager and another user said he solves this problem by putting "importPackage = null" on the top of all scripts.
On the contrary based on the contents of your script I get the feeling you are having trouble importing Java classes. If that's the case I answer that here,
Use a jar in JavaScript through Java ScriptEngine
Basically there is another way to import inside JavaScript that you did not show. I do it this way,
pack = Packages.abc.foo.pack.name;
var foo = new pack.ClassFromTheJarFile("arg1","arg2");
foo.doSomething();
var fooSister = new pack.AnotherCLassFromTheJarFile("arg1");
fooSister.doSomthingFromThisClass();
Although that example uses a package from a jar file it does not have to be from a jar and the code would still remain the same.