# How can i resolve Runtime Error?

**URL:** <https://discourse.processing.org/t/how-can-i-resolve-runtime-error/40710>\
**Category:** Coding Questions\
**Created:** [January 25, 2023, 7:38pm UTC](https://discourse.processing.org/t/how-can-i-resolve-runtime-error/40710 "2023-01-25T19:38:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![happycode](https://avatars.discourse-cdn.com/v4/letter/h/eada6e/32.png) [@happycode](https://discourse.processing.org/u/happycode)\
**Post date:** [January 25, 2023, 7:38pm UTC](https://discourse.processing.org/t/how-can-i-resolve-runtime-error/40710/1 "2023-01-25T19:38:42Z")

</div>

I have written an Java Processing application. If I try to start it, I get the following error:

`""processing.core.PGraphics.createShape(int, float[])" because "this.g" is null".`

My Application has a View, Controller and Modell. They only interact through interfaces with each other. My Modell-Classes extend PApplet and create some shapes, but I also get errors in my view. Maybe something is not passed on correctly.

I know, that the error may be caused, because I try to call a method on an object that has not been initialized yet. In this case the processing.core.PGraphics.createShape(int, float) method on this.g.

My PApplet window opens, but nothing is drawn on it.

Could someone please look into it?

I tried to create instances of PApplet and/or Graphic in my View class and pass it in to my controller class; e.g.:

my View, where the objects are drawn.

```auto

```

public class xyView extends PApplet implements ILeiterspielView {  
public static void main(String args) {  
PApplet.main(LeiterspielView.class);  
}  
…  
private static PApplet instance;  
//other attempt: PApplet p = this;  
//other attempt: PApplet p;  
…  
public xyView (other examples/_PApplet pa_//_Graphics gd_/) {  
instance = this;  
[//this.gd](https://this.gd) = gd;  
[//this.p](https://this.p) = pa;  
setSize(1000, 1000);  
}  
public void setup (/_Dice[] dice_//_this_/) {  
this.controller = new xyController(this, width, height, instance);  
…  
}

```auto

```

my controller, the interface between the view and model.

```auto

```

public LeiterspielController (IxyView view, …, PApplet p) {  
this.view = view;  
this.game = new xyModel();  
this.p = p;  
…  
}

```auto

```

My first solution doesn’t change the outcome.

The PApplet p = this solution changes the outcome to:

> java.lang.RuntimeException: java.lang.NoSuchMethodException: leiterspiel.view.LeiterspielView.()

I don’t know what this means and the PApplet window doesn’t open.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [January 25, 2023, 9:41pm UTC](https://discourse.processing.org/t/how-can-i-resolve-runtime-error/40710/2 "2023-01-25T21:41:55Z")

</div>

In order to “ignite” a PApplet instance I recommend method [**runSketch()**](http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#runSketch-java.lang.String:A-processing.core.PApplet-).

> [@Cannot Export DXF from PWindow?](https://discourse.processing.org/t/cannot-export-dxf-from-pwindow/36767/2):
>
> Check out these 2 examples about using [runSketch()](http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#runSketch-java.lang.String:A-processing.core.PApplet-) + [ARGS\_SKETCH\_FOLDER](http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#ARGS_SKETCH_FOLDER) + [sketchPath()](http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#sketchPath--): [Size method for intial window not working when more windows are are added. - Processing 2.x and 3.x Forum](http://forum.Processing.org/two/discussion/16457/size-method-for-intial-window-not-working-when-more-windows-are-are-added#Item_1)
