[Scilab-users] Question about javasci V2

Daniel Neutzler daniel.neutzler at haw-hamburg.de
Mon Feb 13 13:06:33 CET 2017


Hello Pierre,
thank you for your answer. It is nice to hear that my Problem is 
probably a Bug.
I'm not sure how to use your example. Which Libs do I need for it or may 
you have a simple example to use it?
I'm sorry, my Java knowlegde is restricted (Beginner).

Thank You for your Help,
Daniel Neutzler


Am 04.02.2017 um 19:29 schrieb Perrichon:
>
> Hello Daniel
>
> I’ve already met your problem one year ago, and for me it is really a bug.
>
> I work with scilab x64 5.5.2, netbeans 7.01, on W7 or W10 platform.
>
> I’ve sovled it in my application, so I’m just able to propose parts of 
> code.
>
> I’ve delay the 2 instructions *Scilab sci = new Scilab(true)* and if 
> (sci.open()) {, by creating a ScilabManager class, … and a thread 
> class named  Idle
>
> Part of ScilabManager  (also note the  public static void OpenScilab())
>
> public class ScilabManager {
>
>     public static Scilab sci;       //Driver Scilab
>
> public static boolean bScilabOpen;
>
> public static boolean InitScilab;
>
> public  static Fifo FifoScilab;
>
> private static TListeFifo SciJob;
>
> static ScilabError TErrorScilab;
>
> public static File ScilabFile;
>
> private static int dim = 500;
>
> public static String [] Script;
>
> private static int iScript;
>
>     public static Configuration AppConfiguration;
>
>     public static Log LogScilab;
>
>     public static int NumGraph=0;
>
> ScilabManager() {
>
> try {
>
> sci = new Scilab(true);
>
> InitScilab=true;
>
>        } catch (JavasciException.InitializationException ex) {
>
> Logger.getLogger(ScilabManager.class.getName()).log(Level.SEVERE, 
> null, ex);
>
> }
>
>     }
>
>     @SuppressWarnings("CallToThreadDumpStack")
>
> public static void OpenScilab() {
>
>         try {
>
>             bScilabOpen=sci.open();
>
>         } catch (JavasciException ex) {
>
> ex.printStackTrace();
>
> }
>
>         if (bScilabOpen) System.out.println("\nScilab est ouvert\n");
>
> else System.out.println("\nErreur ouverture Scilab\n");
>
>         ScilabError.ClearScilabError();
>
>         try {
>
> // Initialisation et chargements des fonctions Scilab
>
> //---------------------------------------------------
>
> AppConfiguration = new Configuration();
>
> } catch (FileNotFoundException ex) {
>
>       Logger.getLogger(ScilabManager.class.getName()).log(Level.SEVERE, 
> null, ex);
>
> } catch (IOException ex) {
>
> Logger.getLogger(ScilabManager.class.getName()).log(Level.SEVERE, 
> null, ex);
>
> } catch (JavasciException ex) {
>
>    Logger.getLogger(ScilabManager.class.getName()).log(Level.SEVERE, 
> null, ex);
>
> }
>
>         try {
>
> // Initialisation du fichier de log out (Traces commandes Scilab)
>
> //--------------------------------------------------------------
>
> LogScilab = new Log();
>
> OptsimView.SetLogFile();
>
> } catch (FileNotFoundException ex) {
>
> ex.printStackTrace();
>
> } catch (IOException ex) {
>
> ex.printStackTrace();
>
> }
>
>         Script = new String[dim];
>
> Now note part of Idle task :
>
> public class Idle extends Thread  {
>
>     protected volatile boolean IdleRunning = true;
>
> public static boolean bCloseIdle=false;
>
>     private static int Count=1;
>
> private static int setGraphe=0;
>
>   private static JTextField TF=null;
>
> private static Timer bTimer;
>
> private static JLabel AnimationLabel;
>
> private static Icon idleicone;
>
> private int ThreadNumber;
>
> Idle (JTextField TFi, Timer busyIconTimer,
>
> JLabel statusAnimationLabel, Icon icone) {
>
> TF=TFi;
>
> bTimer=busyIconTimer;
>
> AnimationLabel=statusAnimationLabel;
>
> idleicone=icone;
>
> this.ThreadNumber=Count++;
>
> }
>
> @Override
>
> public synchronized void run() {
>
>     boolean bTest;
>
>     if (ScilabManager.InitScilab) {
>
>             ScilabManager.OpenScilab();
>
> }
>
>     ScilabManager.sci.exec("aPPeScilabJavasciv2=1;");
>
>     while (IdleRunning) { …etc
>
> So instructions *Scilab sci = new Scilab(true)* and if (sci.open are 
> delayed.
>
> This is the only solution I’ve found. After that Scilab well run with 
> Java netbeans and javasci2.
>
> Also well note that my program doesn’t work with Scilab 6.0.0 b2 at 
> compile time and see :
>
> http://bugzilla.scilab.org/show_bug.cgi?id=14626
>
> Hope it helps you
>
> Sincerely
>
> Pierre
>
> *De :*users [mailto:users-bounces at lists.scilab.org] *De la part de* 
> Daniel Neutzler
> *Envoyé :* mardi 31 janvier 2017 13:15
> *À :* users at lists.scilab.org
> *Objet :* [Scilab-users] Question about javasci V2
>
> Hi, I am using Scilab 5.5.2 and trying to open a Scilab script from
> Java. Therfore I followed the documentation: Compute and run with 
> javasci v2.
>
> I use Eclipse to compile and run. It works, but I want now to open it 
> in "advanced mode"  to get grahpics
> (*Scilab sci = new Scilab(true);*). If i do it, I get a compile Error. 
> What's wrong ?
> Code and Error Plot out see below.
>
> Thank You for your Help,
> Daniel Neutzler
>
> ####Error####
> java.lang.ExceptionInInitializerError
>     at org.scilab.modules.commons.xml.XConfiguration.<clinit>(Unknown 
> Source)
>     at org.scilab.modules.core.Scilab.<clinit>(Unknown Source)
>     at 
> org.scilab.modules.javasci.Call_ScilabJNI.Call_ScilabOpen(Native Method)
>     at org.scilab.modules.javasci.Call_Scilab.Call_ScilabOpen(Unknown 
> Source)
>     at org.scilab.modules.javasci.Scilab.open(Unknown Source)
>     at StartUp.main.main(main.java:17)
> Caused by: java.lang.NullPointerException
>     at java.io.File.<init>(Unknown Source)
>     at org.scilab.modules.commons.ScilabConstants.<clinit>(Unknown Source)
>     ... 6 more
> Exception in thread "main"
>
> #### JAVA Code####
>
> package StartUp;
> *import org.scilab.modules.javasci.Scilab;
> import org.scilab.modules.types.ScilabType;*
> import java.io.File;
> import java.io.FileNotFoundException;
>
> public class main {
>
>     public static void main(String[] args) throws FileNotFoundException{
>         System.out.println("Starte Programm Pin-Positionsanalyse-Tool 
> V1.0...");
>
>         try {
> *Scilab sci = new Scilab(true); // Starts in advanced mode *
>             if (sci.open()) {
>             sci.execException(new 
> File("C:/Users/Daniel/Desktop/test.sce"));
>             sci.close();
>              } else {
>                  System.out.println("Could not start Scilab ");
>              }
>     /* Can be improved by other exceptions: AlreadyRunningException,
>     * InitializationException, UndefinedVariableException,
>     * UnknownTypeException, etc
>     */
>          } catch (org.scilab.modules.javasci.JavasciException e) {
>              System.err.println("An exception occurred: " + 
> e.getLocalizedMessage());
>          }
>     }
> }
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20170213/ec604126/attachment.htm>


More information about the users mailing list