Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

running java file using eclipse

Please login with a confirmed email address before reporting spam

Hi all,

I am trying to running a java file (directly savd from COMSOL desktop) using Eclipse. I followed all the instructions and apparently eclipse connect and disconnect to/from COMSOL server correctly, but nothing happens i.e. I cannot visualise any results, although in the java file commands are implemented for postprocessing graphics.
Do you know how to manage such a problem? any solutions and/or hints?

Thank you very much,
Rachele

4 Replies Last Post 08.07.2017, 15:49 GMT-4

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 31.07.2012, 03:20 GMT-4
Hi Rachele

In order to view any results, you need eclipse to export the results with a command like

model.result().export("data1").run();

This command will work for .txt files, but not image files (i'm still trying to figure out the latter). This command is similar to clicking the export button in COMSOL.

A good way to learn use COMSOL with java is to go the end of the APi guide and do the steady state example for a beam they have. I've been able to take that and write my own code. I know you can visualize images from post processing with this tutorial but I am still learning to have it export image files. I can post that later if you need it.

Just having eclipse connect/disconnect will not generate results unless they are exported.

An alternative is to have eclipse run the java file and then you recompile it as a .class file that you reimport into COMSOL.

I hope this helps. I'm working with 4.2a but it shouldn't be too different.
Hi Rachele In order to view any results, you need eclipse to export the results with a command like model.result().export("data1").run(); This command will work for .txt files, but not image files (i'm still trying to figure out the latter). This command is similar to clicking the export button in COMSOL. A good way to learn use COMSOL with java is to go the end of the APi guide and do the steady state example for a beam they have. I've been able to take that and write my own code. I know you can visualize images from post processing with this tutorial but I am still learning to have it export image files. I can post that later if you need it. Just having eclipse connect/disconnect will not generate results unless they are exported. An alternative is to have eclipse run the java file and then you recompile it as a .class file that you reimport into COMSOL. I hope this helps. I'm working with 4.2a but it shouldn't be too different.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 03.08.2012, 07:15 GMT-4
If you want an external image, there is two ways I've figured out thus far. You can use the java method "Robot" to take a screenshot of a GUI generated by COMSOL or have COMSOL export the data in table form and have another program generate the image
If you want an external image, there is two ways I've figured out thus far. You can use the java method "Robot" to take a screenshot of a GUI generated by COMSOL or have COMSOL export the data in table form and have another program generate the image

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 29.06.2017, 08:34 GMT-4
Hi Rachelle,

we are just looking to get a text value for the eig freq, so we can link to external software.

the model computes the freq, we have set up a table and link the computed result to the table.

in GUI mode the txt output file is written with content, in batch mode the message 'cannot open file for writing' appears..

cheers
Hi Rachelle, we are just looking to get a text value for the eig freq, so we can link to external software. the model computes the freq, we have set up a table and link the computed result to the table. in GUI mode the txt output file is written with content, in batch mode the message 'cannot open file for writing' appears.. cheers

Please login with a confirmed email address before reporting spam

Posted: 7 years ago 08.07.2017, 15:49 GMT-4
Updated: 7 years ago 08.07.2017, 15:49 GMT-4
#Chris - It sounds like a permission problem. If you open COMSOL (the GUI) and go to "Preferences", you can control the permission from the security tab. These permissions apply to batch execution also. I guess you need to set "File system access" to "All files", but other permissions might also be relevant.

#Alexander/Rachele - Since all COMSOL graphics are generated "on GUI" there is no native support for off screen rendering. However, it's possible to run COMSOL with GUI in batch mode; simply add the "-graphics" flag when you execute your compiled .class file. A GUI will then pop-up when you need it for graphics exports. I use this option in combination with xvfb (a virtual frame buffer) to generate graphics from COMSOL on our cluster which does not have a display.
#Chris - It sounds like a permission problem. If you open COMSOL (the GUI) and go to "Preferences", you can control the permission from the security tab. These permissions apply to batch execution also. I guess you need to set "File system access" to "All files", but other permissions might also be relevant. #Alexander/Rachele - Since all COMSOL graphics are generated "on GUI" there is no native support for off screen rendering. However, it's possible to run COMSOL with GUI in batch mode; simply add the "-graphics" flag when you execute your compiled .class file. A GUI will then pop-up when you need it for graphics exports. I use this option in combination with xvfb (a virtual frame buffer) to generate graphics from COMSOL on our cluster which does not have a display.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.