When I try to run my COMSOL script from my App GUI, I receive an 'AccessControlException' when trying to load an .STL file from my local hard drive.
AccessControlException: Security preference 'File system access' does not allow 'read' access to 'C:\Users\peter\STL_Examples\beam_0.STL'.
The error gets triggered by the last line of code in the code posted below: model.mesh("mpart1").run();
From this post, I learned that I may be able to solve that problem by using AccessController.doPriviledged(...). However, when I try to import the AccessController in COMSOL, I get an error message stating java.security.AccessController couldn't be resolved to a variable.
import java.security.AccessController;
clearModel(model);
model.component().create("comp1", true);
model.component("comp1").geom().create("geom1", 3);
model.component("comp1").mesh().create("mesh1");
model.component("comp1").geom("geom1").create("imp1", "Import");
AccessController.doPriviledged(
model.component("comp1").geom("geom1").feature("imp1").set("filename", "C:\\Users\\peter\\STL_Examples\\beam_0.STL")
);
model.component().create("mcomp1", "MeshComponent");
model.geom().create("mgeom1", 3);
model.mesh().create("mpart1", "mgeom1");
with(model.component("comp1").geom("geom1").feature("imp1"));
set("mesh", "mpart1");
endwith();
model.mesh("mpart1").create("imp1", "Import");
with(model.mesh("mpart1").feature("imp1"));
set("filename", "C:\\Users\\peter\\STL_Examples\\beam_0.STL");
endwith();
with(model.component("comp1").geom("geom1").feature("imp1"));
set("meshfilename", "");
endwith();
model.mesh("mpart1").run();
How do I import a standard java library in COMSOL? Or, how do I work arround the AccessControl issue?
I found the solution to this issue in the COMSOL Application Settings. In the "File" menu click "Preferences" and select the "Security" section. Then change "File system access:" to 'All files'.