How to Export Sketch? *Urgent*

edited April 2014 in How To...

Hello, I am trying to make my code work on any computer by exporting it as application. I tried exporting it and I also selected Embed and when it is done it gives me a file includes some files and a .bat file with the name of my sketch and when I open it it just blinks a cmd screen and do nothing...

I tried a sketch from examples and it was the same..

What can I do please help me I have to finish this asap

Thank You

Answers

  • Processing is compiled as a Java program! Make sure you got JRE correctly installed at the least!
    Most ideal is having a unique ".jar" generated file. The old Processing v1.5.1 was able to do just that w/ CTRL+E!
    For current Processing 2.x.x series, take a look at SvgExe tool:
    http://forum.processing.org/two/discussion/3903/svgexe-create-standalone-runnable-jars-for-every-system

  • I have seen this amazing program and it works perfectly! But it did not work on my code because my code includes a stream video input! also my final code includes controlling servos via motion detection and via mouse.

    so I have no idea if this would work! will it?

    import processing.video.*;
    
    Capture video;
    
    PImage prevFrame;
    
    float threshold = 150;
    int Mx = 0;
    int My = 0;
    int ave = 0;
    
    int ballX = width/8;
    int ballY = height/8;
    int rsp = 5;
    
    void setup() {
      size(320, 240);
      video = new Capture(this, width, height, 30);
      video.start();
      prevFrame = createImage(video.width, video.height, RGB);
    }
    
    void draw() {
    
    
      if (video.available()) {
    
        prevFrame.copy(video, 0, 0, video.width, video.height, 0, 0, video.width, video.height); 
        prevFrame.updatePixels();
        video.read();
      }
    
      loadPixels();
      video.loadPixels();
      prevFrame.loadPixels();
    
      Mx = 0;
      My = 0;
      ave = 0;
    
    
      for (int x = 0; x < video.width; x ++ ) {
        for (int y = 0; y < video.height; y ++ ) {
    
          int loc = x + y*video.width;            
          color current = video.pixels[loc];      
          color previous = prevFrame.pixels[loc]; 
    
    
          float r1 = red(current); 
          float g1 = green(current); 
          float b1 = blue(current);
          float r2 = red(previous); 
          float g2 = green(previous); 
          float b2 = blue(previous);
          float diff = dist(r1, g1, b1, r2, g2, b2);
    
    
          if (diff > threshold) { 
            pixels[loc] = video.pixels[loc];
            Mx += x;
            My += y;
            ave++;
          } 
          else {
    
            pixels[loc] = video.pixels[loc];
          }
        }
      }
      fill(255);
      rect(0, 0, width, height);
      if (ave != 0) { 
        Mx = Mx/ave;
        My = My/ave;
      }
      if (Mx > ballX + rsp/2 && Mx > 50) {
        ballX+= rsp;
      }
      else if (Mx < ballX - rsp/2 && Mx > 50) {
        ballX-= rsp;
      }
      if (My > ballY + rsp/2 && My > 50) {
        ballY+= rsp;
      }
      else if (My < ballY - rsp/2 && My > 50) {
        ballY-= rsp;
      }
    
      updatePixels();
      noStroke();
      fill(0, 0, 255);
      ellipse(ballX, ballY, 20, 20);
    }
    
  • did you try to start the bat-file from a console-window? that way you could check if there is an error message and what it says.

  • edited April 2014

    What do you mean by console-window? how can I run my code through console-window? The code is running perfectly in processing

    PS: I am using windows 7 pro 64bit and 2.1 processing

    There are a lot of stuff in processing that I do not know yet!

    Thank You..

  • these are all the files in the lib folder..after exporting the code above

    Untitled

  • press start, type cmd, you will see the application cmd.exe. Run that and navigate to the directory with your app (google "cmd navigate to directory"). Then run the bat file from cmd.

  • According to this FAQ http://wiki.processing.org/w/Troubleshooting#Security_Issues you will see this statement about exported applications: "Applets are also not allowed to do things like capture video or audio."

  • @spacewalker - Applet (Java applets running in the browser) support has been dropped in 2.0. This advice, although potentially useful, doesn't apply to exported applications.

  • @calsign - thanks for pointing that out. New user here and just ran across what I thought sounded similar to something I had just read. Thanks again. :)

  • I have tried to open the .bat file from the cmd console-window and it did not work either.. :(

    I need to finish this so I can submit my graduation project :(

    I have seen other project that used stream video in their project GUI so I think that this can work but I have no idea how..

    I would really appreciate it if you give me more options thank you

  • SvgExe should work regardless of your video... assuming that Processing is exporting your native libraries and whatnot correctly, which it doesn't seem to be.

    What error do you get when you run the .bat file from the console? For that matter, what does your .bat look like? Is it setting your native library location correctly?

  • There is no error when I open the .bat file it just blinks a cmd screen for less than a second and nothing happens after that.

    I think the problem is selecting the class's, the external files and the natives all I did at the moment is just selecting the processing .jar and my sketch name .jar

    I do not know what are the external files and the natives. and this is the problem I guess.

    Is there any thing explains how I can know which files are external and natives ?

  • We're asking you to open it from the command line, not by double-clicking it. That will show you the error you're getting instead of just flashing it on the screen.

    What is the text of the .bat file? You should be able to open it with a basic text editor.

    What do you mean you selected the processing jar and your sketch's jar? Selected them where? Which Processing jar?

    You might want to look at the documentation for whatever library you're using that requires those native files.

    • I did open it from CMD (isn't it what you mean? command line) I opened cmd and navigated to the .bat file and opened it and nothing happen.

    • The text is random letters from many languages!

    • I selected the .jar files in the "SvgExe" tool, as I learned from reading it I have to download a processing.jar file from their website and select it with my sketch.jar file when I want to export application.

    • The photo explains what I said earlier "I think the problem is selecting the class's, the external files and the natives all I did at the moment is just selecting the processing .jar and my sketch name .jar"

    1

  • I know I can open .bat files with a basic text editor to see what it's doing. I use JEdit as my basic text editor. You need to determine whether Processing is not setting the native library path correctly, or if some of the native libraries are not being exported correctly. If it's the latter, then you won't be able to run this program until you fix that.

    I suggest creating a basic Processing sketch that doesn't use any libraries or native files. Export that and look at the jar files it generates. You should see the SketchName.jar, and then a bunch of other files. These are the files included in ProcessingLibrary.jar, along with the same files for the other systems.

    Any jar file that is in the output of your more advanced Processing sketch but not in the output of the basic Processing sketch needs to be included in the "jars" section of SvgExe.

    You also need to add all of your native files to SvgExe. You have a bunch of them.

    Actually, it looks like you only have .dll files anyway, so you won't be able to run on multiple systems fro

  • edited April 2014

    The text editor did not do much help as it was just random letters again (I used JEdit this time).

    I did export a basic sketch to see what .jar files it has in common with my sketch and I found 2 extra files I did not add them before so I added them and still did not work while the basic sketch worked just fine!.

    Now I think the problem here is that I do not know which are the native file and which are not! how can I say which one which ?

    PS: My code is up in the 3rd comment you can use it and see if you may

  • Anything that ends in a .dll is a native file, specific to Windows.

  • added the .dll files to native and still did not work :( I wish if there was another way as this way seems to be not working with my code

  • Step 1 is to get the .bat working. I can also open the .bat on my machine with regular ol' notepad. You need to open the .bat to see if it's setting the native library path.

  • edited April 2014

    Some thing happened! there is no more .bat file! its now .exe as in the photo. I have updated processing from 2.1.1 to 2.1.2. also the exported file is now named "application.windows32" instead of "application.windows64"!

    Untitled

  • Yes. For some reason, Processing 64 exports with a .bat to run the sketch while the Processing 32 exports with a .exe.

    You can reuse the previous .bat file you go to run the export in 32-bit mode, though. I did that with previous 2.0 versions which had issues with exporting, as a workaround.

  • I can not use the previous .bat file as I have been deleting them when they were not working, and now I can't make them any more! I only can make the .exe file..

    what else should I do with this .exe file, PhiLho?

Sign In or Register to comment.