Search code examples
javaappletprocessingargvargc

Passing command line inputs to Processing language exported application/applet?


I have created a processing application and then exported it using file->export application. Initially some of the parameters were hard coded to simply make it run. Now I want to supply these (string) parameters using command line while executing the exported application.

I have been trying to look for something similar to C language or Java but it seem that won't work.

I export my application in Win32 and it creates a folder named "application.windows32". Inside the folder there is "myapp.exe" a "source" folder and a "lib" folder. "lib" folder contains "args.txt" and other ".jar files". To run this applet I double click "myapp.exe" and it runs. Could you please tell me what commands will be used inside the processing source-code to achieve:

myapp.exe arg1 arg2?

Any example or suggestions?


Solution

  • Every Processing sketch is a subclass of the PApplet class which has an args property

    Here's a very basic example:

    void setup(){
      if(args != null){
         for(int i = 0; i < args.length; i++) 
            text(args[i],0,10+i*10);
      }
    }
    

    Save this code as a sketch, export it, than run the executable from the command line and pass arguments to see what I mean.