Since you are going to set surface inside the Setup function, you can just declare it without a specific value. Same for canvas. And pay attention to the order in which variables are set. In this case, if canvas where to already be declared with a value outside the function, you‘d end up refering to the surface variable before it has a value.
Try changing PSurfaceFX into a normal PSurface. Since you didn‘t define the sketch differently in size() it should be default, and i doubt the default is fx, and more likely to be an AWT if it‘s Java2D… Anyway, FX probably isn‘t needed for the surface, so just change the Class from FX to the normal variant.
Late to this party, but I have some JavaFX code inside of P5 JAVA to share if anybody finds this helpful. The only note I wanted to add to this thread is often times I work with FX2D in my setup() call.
FIXLIB can be found here, but there’s really no JavaFX specifics in there.