We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have written a Processing sketch that is supposed to run certain code upon exiting (see here). Whenever the program is run in Processing, the shutdown works, but whenever I export the program to run on Windows without Processing, the shutdown code is never executed. What is a possible solution to this problem?
Answers
1st step is write a bare minimum code showing your bug in action! ~:>
Here's a simple as the code can get to demonstrate the problem:
This code, when run in Processing , creates a file named "randomFolder" whenever it is closed. In order for this to be demonstrated in Processing, you should make the randomFile variable an actual file path because having the file generate in the executing folder when in Processing is very strange.
Whenever I tested this code, I had the folder generate on my desktop. Without making changes to the code and exporting for Windows, I ran the program again and the folder did not generate.
I am sorry that the code is messed up in the post. You might find the code easier to read here.
Highlight the code block and hit CTRL+K! ;)
I'm in the dark too! It was supposed to just work!
Gonna paste below the methods tasked to deal w/ the exit process:
https://github.com/processing/processing/blob/master/core/src/processing/core/PApplet.java#L4091
I still have not found a good solution for this just yet. I'll be sure to let you know if I do.
You might also look into adding a shutdown hook using the Runtime.addShutdownHook() method.