Name

Compile and run with javasci — How to compile a Java application using Javasci

Description

To compile a Java code based on Javasci, it is only necessary to have javasci.jar defined in the classpath.

For example, with the code defined in the example of this page, the command would be:

$ javac -cp $SCI/modules/javasci/jar/javasci.jar BasicExample.java

To run Scilab, there are a few other things to set up.

Some global variables must me set:

  • SCI - Path to Scilab files

    • Linux/Unix/MacOSX:

      • In the binary version of Scilab, SCI will point to /path/to/scilab/share/scilab/

      • In the source tree of Scilab, SCI will point to the root of the source tree /path/to/scilab/source/tree/

    • Windows

  • LD_LIBRARY_PATH - Paths to libscilab.so and libjavasci.so (or .dll, .jnilib...)

    • Linux/Unix/MacOSX:

      • In the binary version of Scilab, SCI will point to /path/to/scilab/lib/scilab/

      • In the source tree of Scilab, SCI will point to the root of the source tree /path/to/scilab/modules/javasci/.libs/ and /path/to/scilab/.libs/

To launch the Java Application, you can either provide them with environnement variable

  • LD_LIBRARY_PATH=/path/to/libjavasci/ SCI=/path/to/scilab/ java -cp modules/javasci/jar/javasci.jar:. BasicExample

    or with the arguments

  • SCI=/path/to/scilab/ java -Djava.library.path=/path/to/libjavasci/ -cp modules/javasci/jar/javasci.jar:. BasicExample

Note that two environnement variables are taken in account for specific needs:

  • SCI_DISABLE_TK=1 Disables Tk (Tcl's GUI)

  • SCI_JAVA_ENABLE_HEADLESS=1 Launch Java in headless mode (no AWT/Swing)

Examples

// A simple Java example 
// Filename: BasicExample.java

import javasci.Scilab;

public class BasicExample {
public static void main(String []args){
Scilab.Exec("disp((%pi^2)/6);");
}
}

See Also

Scilab, SciDouble, SciDoubleArray, SciString, SciStringArray

Authors

Allan Cornet

Sylvestre Ledru