MATLAB: Am I getting a java error when trying to run the java class compiled by MATLAB Builder JA 2.2.3 (R2011b)

errorjavajavabuilderjavabuilder.jarMATLAB Compiler SDKmissingnosuchmethoderror

I have compiled a java class using MATLAB Builder JA 2.2.3 (R2011b). When I try to run the class on my Linux machine, I get the following error:
 
Exception in thread "main" java.lang.NoSuchMethodError: com.mathworks.toolbox.javabuilder(Com/mathworks/toolbox/javabuilder/Microphone;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;[I)Com/mathworks/toolbox/javabuilder/internal/MWMCR;
at com.entic.matlab._255_plantoptimizer._255_plantoptimizerMCRFactory.newInstance(_255_plantoptimizerMCRFactory.java:47)
at com.entic.matlab._255_plantoptimizer._255_plantoptimizerMCRFactory.newInstance(_255_plantoptimizerMCRFactory.java:58)
at com.entic.matlab._255_plantoptimizer.PlantOptimizer.<init>(PlantOptimizer.java:62)
at com.entic.matlab.esb._255.ChillerOptimizer.calculateOptimization(ChillerOptimizer.java:24)
at com.entic.matlab.esb._255.ChillerOptimizer.main(ChillerOptimizer.java:63)
I have made sure that the MCR is installed.

Best Answer

The MathWorks javabuilder.jar java library is missing. Make sure the javabuilder.jar file is added to the java class path when running your java class, as below:
 
java -classpath <mwroot>/toolbox/javabuilder/jar/javabuilder.jar:foo.jar foopackage.fooclass
where mwroot is either the MATLAB root directory (if running against MATLAB) or the MCR root directory (if running against the MCR).
If you have another java application that utilizes the compiled java class, make sure to also import it as below:
 
import com.mathworks.toolbox.javabuilder.*