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:

on Linux/Unix/MacOSX:

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

on Windows:

D:\> 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

      • path of scilab root directory:

        set SCI=C:\program files\scilab-5.1

  • LD_LIBRARY_PATH - Paths to libscilab.so and libjavasci.so (or .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/

    • Windows: Path to libscilab.dll and javasci.dll

      • equivalent to LD_LIBRARY_PATH on Windows is PATH

        set PATH="%SCI%\bin";%PATH%

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

  • Linux/Unix/MacOSX:

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

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

    or with the arguments

  • Windows:

    set SCI=c:\program files\scilab-5.1

    set PATH="%SCI%\bin";%PATH%

    D:\java -cp "%SCI%\modules\javasci\jar\javasci.jar";. BasicExample

optional options to launch java : -Djava.compiler=JIT -Xmx256m

(With these arguments , you launch javasci with same initial options that standard scilab).

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

SciDouble, SciDoubleArray, SciString, SciStringArray

Authors

Allan Cornet

Sylvestre Ledru