<span style="color:rgb(73,73,73); font-family:simsun; font-size:14px; line-height:21px; background-color:rgb(255,255,255)"> 考虑到计算的各种情况,有些用Java代码实现的计算难免会显得不够高效。而利用MATLAB写好相应的计算函数,然后打包成jar包供Java调用,在某些情况下会更加方便。或者有些时候会涉及到使用Java调用MatLab展现一些二维三维图。因此用到Java调用MatLab。</span></p>
<p><span style="font-family:simsun; color:#494949"><span style="font-size:14px; line-height:21px">一:注意事项</span></span></p>
<p><span style="font-family:simsun; color:#494949"><span style="line-height:21px"><span style="font-size:14px; white-space:pre"></span>1: <span style="font-size:12px">MatLab<span style="background-color:rgb(255,255,255)"><span style="color:rgb(73,73,73); font-family:simsun; line-height:21px">的版本必须是2006b+(包括2006b或更高版本),因为只有在这些版本中才有</span><span style="word-wrap:normal; word-break:normal; line-height:19.5px; color:rgb(73,73,73); font-family:simsun">MATLAB
Builder for Java(也叫Java Builder)。</span></span></span></span></span></p>
<p><span style="font-family:simsun; font-size:12px; color:#494949"><span style="line-height:21px"><span style="background-color:rgb(255,255,255)"><span style="word-wrap:normal; word-break:normal; line-height:19.5px; color:rgb(73,73,73); font-family:simsun"><span style="white-space:pre"></span>2: 运行机器上必须装有JRE
并且版本要和MatLab自带的jre 大版本保持一致(位数也要保持一致)(大版本一致既可,比如同是1.6,或者1.7既可)</span></span></span></span></p>
<p><span style="font-family:simsun; font-size:12px; color:#494949"><span style="line-height:21px"><span style="background-color:rgb(255,255,255)"><span style="word-wrap:normal; word-break:normal; line-height:19.5px; color:rgb(73,73,73); font-family:simsun"><span style="white-space:pre"></span>
查看MatLab 自带JRE版本位数方法:在MatLab中Command Windows中输入 【version -java】 命令查看。如图所示:</span></span></span></span></p>
<p><span style="font-family:simsun; font-size:12px; color:#494949"><span style="line-height:21px"><span style="background-color:rgb(255,255,255)"><span style="word-wrap:normal; word-break:normal; line-height:19.5px; color:rgb(73,73,73); font-family:simsun"><span style="white-space:pre"><img src="
http://img.blog.csdn.net/20141027100315468?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQva2FsaXNpb24=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""></span> </span></span></span></span></p>
<p><span style="font-family:simsun; font-size:12px; color:#494949"><span style="line-height:21px"><span style="background-color:rgb(255,255,255)"><span style="word-wrap:normal; word-break:normal; line-height:19.5px; color:rgb(73,73,73); font-family:simsun"><span style="white-space:pre"></span>
这里是 1.6.0_17-b04 版本的JRE 并且为64位的。(注意:这里之所以是64位的,取决于您当初下载的MatLab安装包的位数。</span></span></span></span></p>
<p><span style="font-family:simsun; font-size:12px; color:#494949"><span style="line-height:21px"><span style="background-color:rgb(255,255,255)"><span style="word-wrap:normal; word-break:normal; line-height:19.5px; color:rgb(73,73,73); font-family:simsun"><span style="white-space:pre"></span>3:验证系统jdk
jre,系统首先装有Java环境(不在叙述)。 验证jdk,jre版本位数。打开cmd 输入命令 【java -version】 </span></span></span></span></p>
<p><span style="font-family:simsun; font-size:12px; color:#494949"><span style="line-height:21px"><span style="background-color:rgb(255,255,255)"><span style="word-wrap:normal; word-break:normal; line-height:19.5px; color:rgb(73,73,73); font-family:simsun"><span style="white-space:pre"></span>和
【javac -version】分别验证编译和运行版本。也许有读者会想,两个命令查看的结果肯定版本都一样,但是有些情况java和javac</span></span></span></span></p>
<p><span style="font-family:simsun; font-size:12px; color:#494949"><span style="line-height:21px"><span style="background-color:rgb(255,255,255)"><span style="word-wrap:normal; word-break:normal; line-height:19.5px; color:rgb(73,73,73); font-family:simsun"><span style="white-space:pre"></span>的版本还真不一样,比如安装了多个版本的jdk或者不同位数的jdk,如果是以安装的方式安装,那么java版本和位数是以最后一次安装</span></span></span></span></p>
<p><span style="font-family:simsun; font-size:12px; color:#494949"><span style="line-height:21px"><span style="background-color:rgb(255,255,255)"><span style="word-wrap:normal; word-break:normal; line-height:19.5px; color:rgb(73,73,73); font-family:simsun"><span style="white-space:pre"></span>保持一致,因为安装时,会把java.exe拷贝到系统目录一份(例如:win8中的c:/windows/system32)。虽然配置了java环境变量,但是</span></span></span></span></p>
<p><span style="font-family:simsun; font-size:12px; color:#494949"><span style="line-height:21px"><span style="background-color:rgb(255,255,255)"><span style="word-wrap:normal; word-break:normal; line-height:19.5px; color:rgb(73,73,73); font-family:simsun"><span style="white-space:pre"></span>如果java环境变量配置在了path变量值得最后方,由于系统目录配置在了最前方,以前方为准。因此会出现配置无效。照成了以上所说的</span></span>