Introduction > Getting Started > The Model File for Java

The Model File for Java
The model file for Java has the following structure:
import com.comsol.model.*;
import com.comsol.model.util.*;
 
public class feeder_clamp {
 
  public static void main(String[] args) {
    run();
  }
 
  public static Model run() {
    Model model = ModelUtil.create("Model");
    ...
    return model;
  }
}
Any model that you create in the COMSOL Desktop can be saved as a model file for Java.
When you compile a model file for Java into a class file and run it, COMSOL runs exactly those instructions that are included in the model file for Java. When opening an MPH-file and saving it as a Java file only those sequences that have been explicitly run are run in the Java file. But saving it as a model file for Java, the file does not contain a runAll command for the solver sequence. To run a solver sequence, add a line similar to model.sol("sol1").runAll();
(where sol1 is the tag for the solver to run) at the bottom of the Java file, above the line that contains return model;.