SCILAB 是由法国国家信息、自动化研究院(INRIA)的科学家们开发的“开放源码”软件。
Call Scilab engine from a Java application
Description
Scilab offers the possibility to be called from a Java application.
This help describes the features of the javasci API.
Since Scilab version 5.3.0, a new version of Javasci called Javasci v2 has been introduced. This version fixes most of thelimitations of Javasci v1.
Browse the documentation of Javasci v2. (this will open the web browser).
首先是配置java的path,classpath,
新建系统变量JAVA_HOME 和CLASSPATH
变量名:JAVA_HOME
变量值:C:\Program Files\Java\jdk1.7.0
变量名:CLASSPATH
变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
其中变量值为你自己安装jdk的文件目录这里要注意。
选择“系统变量”中变量名为“Path”的环境变量,双击该变量,把JDK安装路径中bin目录的绝对路径,添加到Path变量的值中,并使用半角的分号和已有的路径进行分隔。
变量名:Path
变量值:%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
这是java的环境配置,配置完成后直接启动eclipse,它会自动完成java环境的配置
其次是配置scilib的path和classpath。
set SCI="C:\Program Files\scilab-5.3.0"
set CLASSPATH=%SCI%/modules/javasci/jar/org.scilab.modules.javasci.jar;%SCI%/modules/types/jar/org.scilab.modules.types.jar
set LIB_PATH="%SCI%\bin"
// A simple Java example with javasci v2
// Filename: DisplayPI.java
import org.scilab.modules.javasci.Scilab;
import org.scilab.modules.types.ScilabType;
import org.scilab.modules.types.ScilabDouble;
class Example1 {
public static void main(String[] args) {
try {
Scilab sci = new Scilab();
sci.open();
sci.exec("disp(%pi);");
ScilabDouble a = new ScilabDouble(3.14);
sci.put("a",a);
sci.exec("b=sin(a);");
ScilabType b = sci.get("b");
System.out.println("b = " + b);
sci.close();
} catch (org.scilab.modules.javasci.JavasciException e) {
System.err.println("An exception occurred: " + e.getLocalizedMessage());
}
}
}
将org.scilab.modules.javasci.jar和org.scilab.modules.types.jar两个文件加入到eclipse的classpath中。
参考: ttp://help.scilab.org/docs/5.3.0/en_US/javasci.html
http://blog.sciencenet.cn/blog-412518-436795.html
http://help.scilab.org/docs/5.3.0/en_US/compile_and_run_javasci_v2.html
http://help.scilab.org/docs/5.3.0/en_US/javasci_step_by_step.html