Processing-java and G4P on Mac

Question: How do we set sketchPath and dataPath in processing-java?
Project context: We are creating a game using processing-java where most of our code is java, with some of those files being essentially processing code (i.e. pde files written in java with PApplet etc). We also want to call G4P to build a GUI.
Processing library Because we want to be able to import libraries easily, using github, we cheat by just have the G4P.jar file in our github library (not processing libraries).
Where it works We have the full setup (with G4P) working completley with Linux. We also have the game working (without G4P) in Mac and Linux
Where it doesn’t work It is only when we try to integrate G4P and Mac that we have problems. We did find this forum discussion but we are using Mac OSMojave and we are unclear what to do.
What we have tried We have managed (see screenshot) to identify that the issue is the filepath being overridden (despite the processing-java --sketch-path=). What we find is that without G4P this goes to the correct $PWD for both Macs and Linux, but we don’t understand why G4P is doing this.

Potential solutions

  1. Change working directory with either processing function (undocumented sketchPath and dataPath seem to be getters not setters - although not sure) or java function
  2. Import G4P using the recommended but a library in processing/libraries (or for linux sketchbook/libraries) folder, and import that way - doesnt seem to work however.
1 Like

Are you using the Processing IDE to create the game?

Are you using the application export feature of Processing to build the runtine?

Gradle: No. Currently we use gradle where in dependencies we include a line for G4P compile files('library/G4P.jar') and processing provided group: 'org.processing', name: 'core', version: '3.3.6'.
Question: Would that make a difference? Is there a way we can integrate that functionality?
Another possible solution Convert processing pde file into java file too.

The trouble with problems like this, is that the user tends to make assumptions about the cause so get tunnel vision. Happens to me a lot :grinning:

You are assuming something inside G4P is changing Processing’s sketch and/or data paths but I can assure you that there isn’t. In fact I am not sure it is even possible to do that.

AFAIK these paths are set by Processing when the size() method is executed, that is why it is important that this is the first statement executed in a sketch.

I suggest you try incorporating the jar from another library e.g. PeasyCam or any one of my other libraries (but not Game Control Plus) if you experience the same problem then the issue is probably related to the Mac build itself.

1 Like

Looks like you tried to upload an image as part of your post, but never completed it. Not sure if the image adds information to what you shared in text.


Thanks all for the responses. We managed to solve the problem by converting the main pde file into a java file.