简体   繁体   中英

How to compile&run another PDE file in Processing

I am trying to compile and run another Processing sketch inside one Processing sketch.

I am thinking about using Runtime.getRuntime().exec() , but I don't know what command to use to compile&run the pde file.

This is my file structure:

file structure image

NMAspaceOS.pde is my main pde, it is used to execute and terminate other pdes.The project0, project1, project3 are the Processing projects I am trying to call/run from NMAspaceOS .

This is going to be a little tricky, because you're not just compiling .java files. You need to first compile the .pde file into a .java file. Usually you would rely on the Processing editor to do this for you.

The Processing editor is open source, and you can view all of its code here . You might try digging through that to find the code that converts a .pde file into a .java file.

But honestly, if I were you I'd take a step back and ask myself if I really needed to do this. Can you refactor your approach so you don't have to do this compilation yourself?

Ok, I came back to post my solution here.

Because you can actually compile & run PDE file from the command line tool after you have installed "Processing-java", so you can absolutely run another PDE. This 1 line of code does it:

Runtime.getRuntime().exec("/usr/local/bin/processing-java --sketch=" + sketchFolderPath + " --run");

Just remember to install processing-java from Processsing->Tools

This works on MacOS, and Linux I presume.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM