Redian新闻
>
如何从java中调用Matlab
avatar
如何从java中调用Matlab# Java - 爪哇娇娃
r*u
1
以下程序用javac JavaMatlab.java 可以通过编译.
但是java JavaMatlab运行却出错:
Exception in thread "main" java.lang.NoClassDefFoundError:
com/mathworks/mwt/mesage/MWHandler
大伙说说.
//calling matlab from Java.
import com.mathworks.jmi.*;
public class JavaMatlab{
public static void main (String[] args)
{
String x1="pwd";
try
{
Matlab m = new Matlab();
m.eval(x1);
}
catch (Exception e)
{
System.out.println("error");
}
}
}
avatar
st
2
include matlab jars in your classpath when calling java. at least.

【在 r***u 的大作中提到】
: 以下程序用javac JavaMatlab.java 可以通过编译.
: 但是java JavaMatlab运行却出错:
: Exception in thread "main" java.lang.NoClassDefFoundError:
: com/mathworks/mwt/mesage/MWHandler
: 大伙说说.
: //calling matlab from Java.
: import com.mathworks.jmi.*;
: public class JavaMatlab{
: public static void main (String[] args)
: {

avatar
r*u
3
I have already include the matlab/java/jar/jmi.jar
echo %classpath%
.;c:\matlab6p5\java\jar\jmi.jar;C:\Sun\AppServer\jdk\lib\tools.jar;C:\Sun\AppS
er
ver\jdk\lib\dt.jar;C:\Sun\AppServer\jdk\bin;C:\sun\jar\mysql-connector-java-3.
0.
11-stable-bin.jar;

【在 st 的大作中提到】
: include matlab jars in your classpath when calling java. at least.
avatar
st
4
did you specific it in command line, when you call java xxxx?
that's something like java -cp ..... xxxx
or java -classpath .... xxxx

【在 r***u 的大作中提到】
: I have already include the matlab/java/jar/jmi.jar
: echo %classpath%
: .;c:\matlab6p5\java\jar\jmi.jar;C:\Sun\AppServer\jdk\lib\tools.jar;C:\Sun\AppS
: er
: ver\jdk\lib\dt.jar;C:\Sun\AppServer\jdk\bin;C:\sun\jar\mysql-connector-java-3.
: 0.
: 11-stable-bin.jar;

avatar
r*u
5
Yes, java -classpath .;c:\matlab6p5\java\jar\jmi.jar JavaMatlab
still the same error:
Exception in thread "main" java.lang.NoClassDefFoundError:
com/mathworks/mwt/message/MWHandler

.;c:\matlab6p5\java\jar\jmi.jar;C:\Sun\AppServer\jdk\lib\tools.jar;C:\Sun\AppS
ver\jdk\lib\dt.jar;C:\Sun\AppServer\jdk\bin;C:\sun\jar\mysql-connector-java-3.

【在 st 的大作中提到】
: did you specific it in command line, when you call java xxxx?
: that's something like java -cp ..... xxxx
: or java -classpath .... xxxx

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。