|
2
|
Go to the Libraries tab, select the Classpath entry, and click Add External JARs. Add all JAR files placed in the plugins directory under the COMSOL installation directory (typically C:\Program Files\COMSOL\COMSOL64\Multiphysics). This allows Eclipse to find the definitions of the classes used by the COMSOL API and to run the code in client/server mode. Click Finish.
|
|
3
|
Drag and drop your exported Java file the src folder of your Eclipse project.
|
|
5
|
To run your Java program, you can create a Run Configuration in Eclipse. You do this from Run Configurations on the Run menu in Eclipse. There, select the Environment tab and then click the New button. In the New Environment Variable dialog, add the following variables; then click OK:
|
|
-
|
On Windows, use the Name PATH (on Windows) and enter the following text in Value: <comsolinstalldir>/lib/win64, where <comsolinstalldir> is the directory where COMSOL Multiphysics is installed.
|
|
-
|
On Linux, use the Name LD_LIBRARY_PATH and enter the following text in Value: <comsolinstalldir>/lib/glnxa64:<comsolinstalldir>/lib/glnxa64/gcc:<comsolinstalldir>/ext/graphicsmagick/glnxa64:<comsolinstalldir>/ext/cadimport/glnxa64, where <comsolinstalldir> is the directory where COMSOL Multiphysics is installed. Also add the variable with the Name LD_PRELOAD and enter the Value <comsolinstalldir>/java/glnxa64/jre/lib/amd64/libjsig.so. If the operating system is set to use a comma as the decimal separator, add a variable with the Name LC_ALL and the Value set to C to enforce the COMSOL software to use a period as the decimal separator.
|
|
-
|
On macOS, use the Name DYLD_LIBRARY_PATH and enter the following text in Value: <comsolinstalldir>/lib/maci64:<comsolinstalldir>/ext/graphicsmagick/maci64:<comsolinstalldir>/ext/cadimport/maci64, where <comsolinstalldir> is the directory where COMSOL Multiphysics is installed.
|
|
8
|
You also need to call System.exit(0) at the end of the Java program to terminate the process.
|
|
9
|
To run the code you must first start the COMSOL server. When the server has started note the port number that is written in the console. If this number does not match the number written in the call to ModelUtil.connect you have to edit this call and save the file again.
|