Introduction > Getting Started > Compiling a Model File for Java®

Compiling a Model File for Java®
First make sure that COMSOL Multiphysics is installed. See the COMSOL Multiphysics Installation Guide for more information if required.
Before getting started, also download and install a Java® Development Kit (JDK) from www.oracle.com/technetwork/java/index.html. You need the JDK to compile the Java file that COMSOL generates. You must compile your Java files with JDK 1.7 or lower.
To test compiling a model files for Java, load feeder_clamp.mph from the COMSOL Multiphysics Applications Libraries into the COMSOL Desktop.
You can learn most of the syntax for creating a model using the COMSOL API by first creating a model using the COMSOL Desktop and then saving the model as an application file for Java.
To open the Application Libraries window:
From the Home toolbar, Windows menu, select Application Libraries (). When a toolbar is compressed, you sometimes select it from the Windows> menu.
You can also customize the Quick Access Toolbar and then click the Application Libraries () button on the toolbar.
Select Application Libraries from the File menu.
To open the Application Libraries window:
On the Main Toolbar, click the Application Libraries () button.
Select Windows>Application Libraries.
In the Application Libraries tree, expand COMSOL Multiphysics and then Structural Mechanics. Select the feeder_clamp model, then click the Open button to open it. To get a Java file to compile, choose Save As from the File menu and choose Model file for Java (*.java) as the file type. It is suggested that you save the file as feeder_clamp.java in your home directory.
To compile feeder_clamp.java, enter
<COMSOL path>\bin\win64\comsolcompile -jdkroot <JDK path>     feeder_clamp.java
on Windows and
<COMSOL path>/bin/comsol compile -jdkroot <JDK path> \     feeder_clamp.java
on Linux and Mac, where <COMSOL path> is the COMSOL installation directory and <JDK path> is the installation directory for the JDK.