Auto run processing sketch

edited April 2014 in Using Processing

Is it possible to start a sketch with processing, and have it run automaticly. When I launch the .pde file, I still have to click "RUN".

Answers

  • A ".pde" file is just a text. It still needs to be compiled in order to run!
    You gotta export the sketch in order to get an executable from it!

  • edited April 2014

    If i export it and run the processing.bat, i get this error

    Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: jssc.SerialNativeInterface.getSerialPortNames()[Ljava/lang/String;
            at jssc.SerialNativeInterface.getSerialPortNames(Native Method)
            at jssc.SerialPortList.getWindowsPortNames(SerialPortList.java:309)
            at jssc.SerialPortList.getPortNames(SerialPortList.java:298)
            at jssc.SerialPortList.getPortNames(SerialPortList.java:182)
            at processing.serial.Serial.list(Unknown Source)
            at Processing.setup(Processing.java:24)
            at processing.core.PApplet.handleDraw(PApplet.java:2359)
            at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:240)
            at processing.core.PApplet.run(PApplet.java:2254)
            at java.lang.Thread.run(Unknown Source)
    

    And by the way here is the sketch

     import processing.serial.*;
     Serial port;
     int last = 1;
    
     void setup()  {
      port = new Serial(this, Serial.list()[1], 9600);
      print(port.port);
    }
     void draw() {
      String onoroff[] = loadStrings("Stat.txt");
      if (last == 0) {
        if (onoroff[0].equals("H") == true) {
          port.write('H');
          print("H");
          last = 1;
        }
      } 
      if (last == 1) {
        if (onoroff[0].equals("L") == true) {
          port.write('L');
          print("L");
          last = 0;
        }
      }
      delay(200);
     }
    

    Any idea ?

  • Anyone ?

  • Does it run in ide?

  • That error is caused by not having the native libraries on your native library path. Is Processing setting the native library path correctly?

    Shameless self-promotion: you can create a self-extracting runnable jar file that handles the native libraries automagically using SvgExe

  • Chrisir The porgram works perfect on the ide :)

    KevinWorkman Can you explain a bit more detailed how i can fix it ?

  • Well, you need to make sure you're setting the native library path correctly. What is in the .bat file? Does it set the native library path before running?

  • @KevinWorkman, I used SvgExe and loved it! It is very easy to use and worked perfectly on my x86 Windows 8. However, I would also like to export my application on Linux and hopefully Mac. Is there any special method to creating a single executable file on these systems, perhaps a .app? Also, is it possible to change the default icon that appears in Windows Explorer and on the dock?

  • Sorry about the multiple comments, my computer just freaked out a little :|

  • Processing 2.0.x was the last series able to export to multiple OSes!
    And Processing 1.5.1 was the last version which natively exported as ".jar" to all OSes!

  • Roch: You can absolutely export a .jar that works on every system. That's exactly what SvgExe is for. You just have to use the ProcessingLibrary.jar file that I put together as outlined in this tutorial: http://staticvoidgames.com/tutorials/deployment/BasicProcessingExample.jsp

    Creating a .app (from a Windows computer) is a bit trickier, but you can do it using JWrapper: http://www.jwrapper.com/

    There isn't a way to change the icon for just your jar, but you can also use JWrapper to create a .exe which you can have an icon for. I just prefer jars because I only need one file for every system.

  • Thank you! I'll try out JWrapper

  • edited April 2014

    KevinWorkman

    In the application.windows64 there is lib, source and myprogram.bat.

    In the lib there is args.txt, core.jar, gluegen-rt.jar, gluegen-rt-natives-windows-amd64.jar, jogl-all.jar, jogl-all-natives-windows-amd64.jar, jssc.jar, jssc.txt, jSSC-2.8.dll, processing.jar and serial.jar.

    And in the bat file is "@echo off java -Djava.ext.dirs=lib -Djava.library.path=lib Processing"

  • edited April 2014

    any idea

  • Running the myprogram.bat should open your program via the command line. Is this not happening or are you confused about the contents of the folder?

  • I get the error showed in the third comment

  • Yes, the problem is still that your native library path isn't being set correctly. This is either because the .bat file doesn't include the setting, or because Processing didn't export the correct native libraries.

    I think you have the same problem as this thread: http://forum.processing.org/two/discussion/4576/how-to-export-sketch-urgent#Item_18

  • I have been battling this for a while.

    Some sketches only work right in the IDE. They fail or run slow when exported.

    Say you have an installation piece. You need to automate the startup and shutdown. But how if nothing is around to click?

    It would be great if this was in the preferences. As it is a button within the program is is certainly accessible.

    Anyways, I have used "Auto Mouse Click" to automate a mouse clicking the run button.

    I hope this can help https://www.murgee.com/auto-mouse-click/

Sign In or Register to comment.