# colorMode throws nullPointerException (java - eclipse)

**URL:** https://discourse.processing.org/t/colormode-throws-nullpointerexception-java-eclipse/18581
**Category:** Coding Questions
**Created:** [March 11, 2020, 12:51am UTC](https://discourse.processing.org/t/colormode-throws-nullpointerexception-java-eclipse/18581 "2020-03-11T00:51:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![leo.nerd](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/leo.nerd/32/6101_2.png) [@leo.nerd](https://discourse.processing.org/u/leo.nerd)
#### Post date: [March 11, 2020, 12:51am UTC](https://discourse.processing.org/t/colormode-throws-nullpointerexception-java-eclipse/18581/1 "2020-03-11T00:51:54Z")

</div>

Hello. I’m coding my project in Eclipse. I’m trying to change the colorMode to HSB:

```auto
import processing.core.PApplet;
public void settings(){
public class mySketch extends PApplet{

	public static void main(String[] args) {
		String[] processingArgs = {"MySketch"};
		MySketch mySketch = new MySketch();
		PApplet.runSketch(processingArgs, MySketch);
	}

	public void settings() {
  	g.colorMode(HSB);
	println(g.colorMode); 
	}
}

```

both lines result in a NullPointerException error:

```auto
java.lang.NullPointerException
	at mySketch.settings(mySketch.java:58)
	at processing.core.PApplet.handleSettings(PApplet.java:978)
	at processing.core.PApplet.runSketch(PApplet.java:10897)
	at mySketch.main(mySketch.java:26)

```

Help!  
Thank you  
L.

---

<div class="post-metadata">

### Author: ![LuckSmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lucksmith/32/5805_2.png) [@LuckSmith](https://discourse.processing.org/u/LuckSmith)
#### Post date: [March 11, 2020, 4:15am UTC](https://discourse.processing.org/t/colormode-throws-nullpointerexception-java-eclipse/18581/2 "2020-03-11T04:15:21Z")

</div>

What does the `g` stand for? Is it initialized properly?

---

<div class="post-metadata">

### Author: ![leo.nerd](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/leo.nerd/32/6101_2.png) [@leo.nerd](https://discourse.processing.org/u/leo.nerd)
#### Post date: [March 11, 2020, 1:09pm UTC](https://discourse.processing.org/t/colormode-throws-nullpointerexception-java-eclipse/18581/3 "2020-03-11T13:09:55Z")

</div>

It’s the reference to the PApplet’s default PGraphics if I understand the doc correctly

[https://processing.github.io/processing-javadocs/core/index.html?processing/core/PApplet.html](https://processing.github.io/processing-javadocs/core/index.html?processing/core/PApplet.html)

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [March 23, 2020, 2:41am UTC](https://discourse.processing.org/t/colormode-throws-nullpointerexception-java-eclipse/18581/4 "2020-03-23T02:41:49Z")

</div>

Were you able to resolve this issue?

I believe that you need to manipulate g in `setup()` – not `settings()`.

Here is the reference for `settings()`:

- [https://processing.org/reference/settings\_.html](https://processing.org/reference/settings_.html)

Define `size()` in settings. Then g is initialized. Then you can configure it in `setup()`.
