Not sure if this helps, here is the wiki for headless mode: Running witout a dispaly.
Related to running code, could you export your application? In Windows the operation generates and executable. I just tested this in Linux and it works the same way. You need to go into one of those generated folders and find the executable which will have the same name as the name of your sketch.
Related to your error Caused by: java.lang.NoClassDefFoundError: processing/core/PApplet, I would recommend you copy the core.jar file into your a folder named code and place this folder within your sketch folder. This is not the best way to do this but it should work as it will ensure you have access to the Processing definition in core.jar. Notice this assumes you are not using any other contributed library or external resources aka other jars. Do this if exporting your application doesn’t work for you.
Kf