Hello @svan,
Cool beans!
I managed to get this to run with Windows with some necessary modifications:
Changes made here:
void runAction()
void runAction() {
String runFilePath = "";
String folderPath = "";
int selectedIndex = tabbedPane.getSelectedIndex();
for (int i = 0; i < files.size(); i++) {
String path = files.get(i);
if (i == selectedIndex) {
runFilePath = path;
println(path);
// logArea.append("runAction : runFilePath = " + runFilePath + "\n");
}
}
int lastSlashIndex = runFilePath.lastIndexOf(File.separator);
if (lastSlashIndex != -1) {
folderPath = runFilePath.substring(0, lastSlashIndex);
// logArea.append("runAction : folderPath = " + folderPath + "\n");
} else {
logArea.append("No path separator found.");
}
if (lastSlashIndex != -1) {
folderPath = runFilePath.substring(0, lastSlashIndex);
} else {
folderPath = System.getProperty("user.dir"); // Default to current directory
println(folderPath);
logArea.append("No path separator found. Using current directory: " + folderPath + "\n");
}
println(codeDir);
String sketchStr = "--sketch=" + codeDir;
logArea.append("Generated command: " + cmdStrExe + " cli " + sketchStr + " --run\n");
ProcessBuilder processBuilder = new ProcessBuilder(cmdStrExe, "cli", sketchStr, "--run");
try {
process = processBuilder.start();
BufferedReader stdIn = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader stdErr = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String outStr = "";
while ((outStr = stdIn.readLine()) != null) {
logArea.append(outStr + "\n");
println(outStr);
}
String errStr = "";
while ((errStr = stdErr.readLine()) != null) {
logArea.append(errStr + "\n");
}
// Wait for the process to complete and get its exit value
int exitCode = process.waitFor();
logArea.append("\nProcess exited with code: " + exitCode + "\n");
}
catch (IOException | InterruptedException e) {
logArea.append(e + "\n");
}
}
This was a quick challenge. I did not comment changes. You can do a file compare. :)
The Processing PDE files are required.
Processing 4.3.4 is the last one to use processing-java.exe for Windows and works with that version. It did not work with Processing 4.4.10 or standalone.
This does not exist as a file:
processing-cli
The correct usage of the cli command is in example I provided.
Windows Terminal (command prompt) output
C:\Users\GLV>processing --help | more
Usage: processing [<options>] [<sketches>]... <command> [<args>]...
Start the Processing IDE
Options:
-v, --version Print version information
-h, --help Show this message and exit
Arguments:
<sketches> Sketches to open
Commands:
lsp Start the Processing Language Server
cli
contributions Manage Processing contributions
sketchbook Manage the sketchbook
sketch Manage a Processing sketch
C:\Users\GLV>processing cli --help | more
Command line edition for Processing 4.4.10 (Java Mode)
--help Show this help text. Congratulations.
--sketch=<name> Specify the sketch folder (required)
--output=<name> Specify the output folder (optional and
cannot be the same as the sketch folder.)
--force The sketch will not build if the output
folder already exists, because the contents
will be replaced. This option erases the
folder first. Use with extreme caution!
--build Preprocess and compile a sketch into .class files.
--run Preprocess, compile, and run a sketch.
--present Preprocess, compile, and run a sketch in presentation mode.
--export Export an application.
--variant Specify the platform and architecture (Export only).
--no-java Do not embed Java.
Starting with 4.0, the --platform option has been removed
because of the variety of platforms and architectures now available.
Use the --variant option instead, for instance:
variant platform
------------- ---------------------------
macos-x86_64 macOS (Intel 64-bit)
macos-aarch64 macOS (Apple Silicon)
windows-amd64 Windows (Intel 64-bit)
linux-amd64 Linux (Intel 64-bit)
linux-arm Linux (Raspberry Pi 32-bit)
linux-aarch64 Linux (Raspberry Pi 64-bit)
The --build, --run, --present, or --export must be the final parameter
passed to Processing. Arguments passed following one of those four will
be passed through to the sketch itself, and therefore available to the
sketch via the 'args' field. To pass options understood by PApplet.main(),
write a custom main() method so that the preprocessor does not add one.
https://github.com/processing/processing/wiki/Command-Line
:)
