I have solved this problem as below. It may not be the best solution but usable.
- First, open your package in idea and import the package.
- Build the module.
- Run javaaddpath in Matlab, the path is the one where the compiled xxx.class is exist in the 'out' folder of idea.(see blow)
- If the class is inside a package, then use:
var = javaObject('packageName.className');
Now you can use the Java class in package.