Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.1 - Français

Change language to:
English - 日本語 - Português

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
However, this page did not exist in the previous stable version.

Aide Scilab >> Interface avec Java > Javasci v1 (deprecated) > Compile and run with javasci v1

Compile and run with javasci v1

How to compile a Java application using Javasci v1. Deprecated: Please use Javasci v2

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

  • Browse the documentation of Javasci v2.
  • Javasci — Call Scilab engine from a Java application
  • Javasci v1 FAQ — The frequently asked questions - Javasci v1. Deprecated: Please use Javasci v2
  • SciDouble — Class to use double object with scilab. Deprecated: Please use Javasci v2
  • SciDoubleArray — Class to use real matrix in Scilab. Deprecated: Please use Javasci v2
  • SciString — Map a Java String into a Scilab string. Deprecated: Please use Javasci v2
  • SciStringArray — Classe to use String matrix in Scilab. Deprecated: Please use Javasci v2

Authors

Allan Cornet

Sylvestre Ledru

<< javasci.Scilab (deprecated) Javasci v1 (deprecated) javasci FAQ >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Mar 03 11:00:16 CET 2011