Quantcast
Channel: Latest Discussions - COMSOL Forums
Viewing all articles
Browse latest Browse all 5773

File access using Java API in batch mode

$
0
0

Hi,

I am currently experimenting with Java API for using COMSOL. I have discovered that I have a problem with external files when using comsolbatch.

The following code (see bottom of post) is for a simple model which opens a basic geometry from the file "SimpleSphere.mphbin" which is located in my model working directory D:\WK. If I compile this to a .class file and open this in the COMSOL interface the model works as expected. However if I open this in batch mode I get the error message below. However if I copy the the file "SimpleSphere.mphbin" to the file location of comsolbatch.exe then the .class file runs with no errors in batch mode.

I believe that COMSOL should be able to locate the file, since I have specified the model working directory with the line model.modelPath("D:\WK");

I also believe that there should be no problem with COMSOL security settings since I have unchecked "Enforce security restrictions".

Please could somebody knowlegable about this offer their opinion. You can assume that I don't know much about java programming.

Kind regards

< error message >


COMSOL 5.1.0.136 progress output file


Mon Oct 22 17:02:40 KST 2018 COMSOL 5.1 (Build: 136) starting in batch mode Running: D:\WK\Test_01.class

/******************/ /*****Error********/ /******************/ access denied ("java.io.FilePermission""D:\WK\SimpleSphere.mphbin""read") Saving model: D:\WK\Test_01_out_Model.mph Save time: 1 s. Total time: 4 s.

< end error message >

{ /* * Test_01.java */

import com.comsol.model.*; import com.comsol.model.util.*;

public static Model run() { Model model = ModelUtil.create("Model");

model.modelPath("D:\\WK");

model.label("Test_01.mph");

model.comments("Untitled\n\n");

model.modelNode().create("comp1");

model.file().clear();

model.geom().create("geom1", 3);

model.mesh().create("mesh1", "geom1");

model.geom("geom1").create("imp1", "Import");
model.geom("geom1").feature("imp1").set("filename", "SimpleSphere.mphbin");
model.geom("geom1").feature("imp1").set("type", "native");
model.geom("geom1").feature("imp1").importData();

model.mesh("mesh1").run();

return model;

}

public static void main(String[] args) { run(); }

} }


Viewing all articles
Browse latest Browse all 5773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>