I got a response from MathWorks support. Basically, importing java classes and using class names is not supported in scripts (but is supported in functions). There are 2 solutions:
1. Use full class names
2. Put your code into a separate matlab function, i.e.:
function x = foo()
import java.lang.Math;
x = Math.round(10.12);
Best Answer