I am facing problem in running MATLAB code from Java. If you know something on this, could u please help me out?
If you don't want to buy MathWork's MATLAB Builder for Java Toolbox, you can use MATLAB's undocumented JMI (Java-MATLAB Interface). Search the CSSM newsgroup (or Google) for JMI, or JMatLink which is based on JMI. The MATLAB code itself is full of JMI usage examples - search "jmi" using the MATLAB Editor's search tool over the entire MATLAB installation.
Note that JMI is neither documented nor officially supported by MathWorks. Moreover, if improperly used it can hang or crash your application. But it's free, unlike the toolbox.