Troubleshooting global null pointer exception

Hello Processing chums!

I have a quite large multi-tab Processing program which is suddenly and unexpectedly failing to startup (I suspect because of a trivial one-character editing accident or something, but due to a different issue I have no backup!) and I’m getting a runtime exception which seems to hinge on this from the stack trace:

Caused by: java.lang.NullPointerException
	at mugen2.<init>(mugen2.java:2381)

Where the <init> I believe means that the exception is happening before any functions are called, so somewhere in the setting of globals. Is there a way to see the actual code that the IDE generates, so I can look at line 2831?

Thanks in advance for any tips!

cheers,
Toby

Hi! Can you be a bit more specific about the problem? Do you mean when you run your program, it fails with that error message? Do you see the window appearing or not?

When you use the processing-java command, if I remember correctly you get all the internal files in the directory specified as output

Thanks micuat. On running the program it fails immediately with this error message, and the canvas window does not appear.

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at processing.core.PApplet.runSketch(PApplet.java:10852)
	at processing.core.PApplet.main(PApplet.java:10620)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at processing.core.PApplet.runSketch(PApplet.java:10846)
	... 1 more
Caused by: java.lang.NullPointerException
	at mugen2.<init>(mugen2.java: 2381)
	... 6 more
RuntimeException: java.lang.reflect.InvocationTargetException

I tried using processing-java (and reinstalled it now as github suggests. I am on macOS 10.15.7) but while it can run the program (and get the same error) the --output DIR option results in no files being written in DIR :slight_smile:

Toby

I tried it on my own but when I run a “valid” code with processing-java, it does output the java file in the directory specified with --output option.

and even an “invalid” code like below seems to end up with a java file although java compiler aborts with an error

float a = frameRate();
void setup()
{
  size(400,400);
  background(255,0,0);
}

could you check first with trying compiling a simple sketch (like void setup(){}) to see if it is output as a java file? If not you have issues with the command line. If it outputs, then there may be an issue with your code.

Thank you again micuat. It’s working fine now! I think the issue may have been my incorrect ordering of the args to processing-java. As specified on GitHub, the args must be in a specific order, and paths given must be full paths. So, this works fine, and I see the Java generated:

processing-java --sketch=/Users/toby/Desktop/pj --output=/Users/toby/Desktop/pj/output --build

Thank you for your help!