当我试图从我的App GUI运行我的COMSOL脚本时,当我试图从我的本地硬盘驱动器加载.STL文件时,我收到一个'AccessControlException‘。
AccessControlException: Security preference 'File system access' does not allow 'read' access to 'C:\Users\peter\STL_Examples\beam_0.STL'.错误由以下代码中的最后一行代码触发: model.mesh("mpart1").run();
从this post中,我了解到我也许可以通过使用AccessController.doPriviledged(...)来解决这个问题。但是,当我尝试在COMSOL中导入AccessController时,我得到一条错误消息,指出无法将java.security.AccessController解析为变量。
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();如何在COMSOL中导入标准java库?或者,我该如何解决AccessControl问题?
发布于 2019-08-14 05:28:53
我在COMSOL应用程序设置中找到了这个问题的解决方案。在“文件”菜单中,单击“首选项”,然后选择“安全”部分。然后将“文件系统访问:”更改为“所有文件”。

https://stackoverflow.com/questions/57484606
复制相似问题