Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: Français - Português - Русский - 日本語
Scilab Help >> Java Interface > javasci

javasci

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 the limitations of Javasci v1.

Browse the documentation of Javasci v2. (this will open the web browser).

Example of Javasci v2

// 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());
      }

    }
}

See Also

History

VersionDescription
5.4.0 Javasci v1 is removed.
5.4.0 New methods added:
  • Scilab.execException(String)

    Same as Scilab.exec(String) but returns an exception when a Scilab error occurs

  • Scilab.execException(String[])

    Same as Scilab.exec(String[]) but returns an exception when a Scilab error occurs

  • Scilab.execException(File)

    Same as Scilab.exec(File) but returns an exception when a Scilab error occurs

5.4.0
  • Javasci supports sparse and boolean sparse datatypes.
  • Javasci supports tlists, mlists and lists datatypes.
  • Javasci supports polynomial datatypes.
  • Javasci supports struct datatypes under the form of an mList.

Comments

Author : Sylvestre LEDRU posted the 01/02/2011 16:07
For now, the javadoc is not available on this website.
Reply to this comment
Please login to comment this page

Author : Sylvestre LEDRU posted the 02/02/2011 14:23
Here is an other easy example:

------ Example1.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);");

double [][]data={{42, Math.PI}};
ScilabDouble a = new ScilabDouble(data);
sci.put("a",a);
sci.exec("b=cos(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());
}

}
}

------------
Reply to this comment
Please login to comment this page
Author : Sayyed Ali Hossayni posted the 31/08/2014 15:39
I receive an error in running this
Exception in thread "main"
java.lang.UnsatisfiedLinkError:
org.scilab.modules.javasci.Call_ScilabJNI.getDouble(Ljava/lang/String;)[[D

I suppose that that is because my jar files are old (I downloaded them from other websites)
how can I download the two important jar files from your website?
More I searched, less I found.
Reply to this comment
Please login to comment this page

Author : Sayyed Ali Hossayni posted the 31/08/2014 16:12
The problem (lack of jar files) was solved.
After installation of the newer version of the scilab (5.5.0), you can find them in your program files, if you are a windows user
Reply to this comment
Please login to comment this page

Author : Sayyed Ali Hossayni posted the 31/08/2014 16:27
The problem (lack of jar files) was solved.
After installation of the newer version of the scilab (5.5.0), you can find them in your program files, if you are a windows user
Reply to this comment
Please login to comment this page



Add a comment:
Please login to comment this page.

Report an issue
<< Compile and run with javasci v2 Java Interface javasci FAQ >>

Scilab Enterprises
Copyright (c) 2011-2015 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Wed Jun 15 08:27:55 CEST 2016