Why is my "dataPath()" wrong?

edited January 2014 in Using Processing

Hi,

The example given here is on a Mac, but I don't think it matters much. I have a problem that appeared after exporting my project as an application. Basically, when I use the Processing IDE to run my code, when I call dataPath(), it doesn't return the correct path, ie ".../Processing/MyProject/data/" but instead, I have something like "/Applications/data".

However, after compiling it, I have the correct path, ie: "/.../Processing/MyProject/application.macosx/MyProject.app/Content/Resources/Java/data/"

Anyone knows how I can have the correct path even when running my code with the Processing app?

Thanks.

Best, Diyoyo.

Answers

  • Actually, it seems to happen only when I put a

    static public void main(String args[]){ }

    method in my file.

    So I guess that's the problem, but I don't know how to solve it, because I need to pass arguments to my application...

  • edited January 2014 Answer ✓

    Generally, we shouldn't override main(), b/c that's the part which instantiates & runs Processing's own framework (PApplet);
    which later on will callback our customized setup() & draw() and the rest of the event functions if present!

    Nonetheless, the framework conveniently stores any passed arguments into args[] field: ;)

    println(args);
    
  • Oh, great, thanks a lot :D

    Now it works from the command line in MacOS when I type: open MyProject.app --args myargs

    However, I don't know what should be the structure of the command in the cmd.exe in Windows. I have tried MyProject myargs

    but it doesn't work... Should I modify the bat file?

Sign In or Register to comment.