Is there any way to pass arguments to the Sketch via processing-java?

I'd like to be able to pass arguments to my sketch:

$ processing-java --sketch=... --force --output=dir --run Arg1 Arg2 Arg3

Since I can't re-implement main(), does Processing grab any additional arguments passed on the command line when using processing-java and make them available to the sketch?

Answers

  • Nope, doesn't work. processing-java launches Commander, which consumes all the arguments, then launches the sketch (after building it, etc). The args are not preserved.

  • edited May 2014

    I've never used "processing-java" to launch anything up till now! X_X
    My attempt, as you can see in the link above, is by running the script generated after exporting the app w/ CTRL+E!

    I try to pass args to the sketch through the generated script in the command line.
    However, they're 100% ignored due to the order they're passed inside the pre-processor's generated main() template! ~X(
    @benfry refuses to acknowledge that replying that's the way it's gotta be w/o saying why! b-(

    In order to patch that, we gotta implement our own main(), overriding the default.
    It's posted there already, but here's that again below: :bz

    public static final void main(String[] args) {
      final String sketch = Thread.currentThread()
        .getStackTrace()[1].getClassName();
    
      PApplet.main(append(args, sketch));
    }
    
  • reading this I just found that windows64 doesn't contain a exe but only a .bat-file in processing version 2.0

    how can I get the exe-file for win64?

    Thanks!

    ;-)

    @echo off
    java -Djava.ext.dirs=lib -Djava.library.path=lib ArgsTest1
    
Sign In or Register to comment.