# Troubleshooting global null pointer exception

**URL:** <https://discourse.processing.org/t/troubleshooting-global-null-pointer-exception/28437>\
**Category:** Processing\
**Created:** [March 11, 2021, 1:39pm UTC](https://discourse.processing.org/t/troubleshooting-global-null-pointer-exception/28437 "2021-03-11T13:39:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![toby](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/toby/32/5434_2.png) [@toby](https://discourse.processing.org/u/toby)\
**Post date:** [March 11, 2021, 1:39pm UTC](https://discourse.processing.org/t/troubleshooting-global-null-pointer-exception/28437/1 "2021-03-11T13:39:36Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [March 11, 2021, 8:12pm UTC](https://discourse.processing.org/t/troubleshooting-global-null-pointer-exception/28437/2 "2021-03-11T20:12:22Z")

</div>

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

> **[processing/processing](https://github.com/processing/processing/wiki/Command-Line)**
>
> Command-Line

---

<div class="post-metadata">

**Author:** ![toby](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/toby/32/5434_2.png) [@toby](https://discourse.processing.org/u/toby)\
**Post date:** [March 11, 2021, 9:05pm UTC](https://discourse.processing.org/t/troubleshooting-global-null-pointer-exception/28437/3 "2021-03-11T21:05:10Z")

</div>

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

```auto
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](https://github.com/processing/processing/wiki/Command-Line) 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 🙂

Toby

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [March 12, 2021, 11:04am UTC](https://discourse.processing.org/t/troubleshooting-global-null-pointer-exception/28437/4 "2021-03-12T11:04:09Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![toby](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/toby/32/5434_2.png) [@toby](https://discourse.processing.org/u/toby)\
**Post date:** [March 14, 2021, 10:54am UTC](https://discourse.processing.org/t/troubleshooting-global-null-pointer-exception/28437/5 "2021-03-14T10:54:35Z")

</div>

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](https://github.com/processing/processing/wiki/Command-Line), 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!
