# URCap error when pressing button

**URL:** <https://forum.universal-robots.com/t/urcap-error-when-pressing-button/27262>\
**Category:** URCap Development\
**Created:** [March 9, 2023, 7:31am UTC](https://forum.universal-robots.com/t/urcap-error-when-pressing-button/27262 "2023-03-09T07:31:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon50669273](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@anon50669273](https://forum.universal-robots.com/u/anon50669273)\
**Post date:** [March 9, 2023, 7:31am UTC](https://forum.universal-robots.com/t/urcap-error-when-pressing-button/27262/1 "2023-03-09T07:31:16Z")

</div>

Hi together,

i am trying to create a simple URCap. By pressing a button the robot should move to a specific position. As soon as I press the button, i get a error:

![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/8/83a191e96ff3f30fe94bef9fb26f146b0833ec96.png)

What could be the issue?

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [March 10, 2023, 1:22pm UTC](https://forum.universal-robots.com/t/urcap-error-when-pressing-button/27262/2 "2023-03-10T13:22:22Z")

</div>

Null pointers usually indicate you are trying to preform a method on an object that has not been instantiated. So what I mean by this is if you have:

```auto
JButton myButton;

myButton.onMouseClick(printToTheScreen("Button Clicked"))) //Not a real function, but you get the idea.

```

You will get a nullpointer every time you clicked the button instead of seeing “Button Clicked” printed to the screen. This is because we have DECLARED myButton, but we have not INITIALIZED it. We need to change the previous code to something like this:

```auto
JButton myButton = new JButton("Click Me"); //Adding new JButton() creates an instance of a button. This will avoid the nullpointer

myButton.onMouseClick(printToTheScreen("Button Clicked")))

```

---

<div class="post-metadata">

**Author:** ![anon50669273](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@anon50669273](https://forum.universal-robots.com/u/anon50669273)\
**Post date:** [March 10, 2023, 1:32pm UTC](https://forum.universal-robots.com/t/urcap-error-when-pressing-button/27262/3 "2023-03-10T13:32:15Z")

</div>

I will try that. thank you very much!

---

<div class="post-metadata">

**Author:** ![eric.feldmann](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@eric.feldmann](https://forum.universal-robots.com/u/eric.feldmann)\
**Post date:** [March 10, 2023, 2:07pm UTC](https://forum.universal-robots.com/t/urcap-error-when-pressing-button/27262/4 "2023-03-10T14:07:17Z")

</div>

Also, the stack trace indicates this is taking place in the “start\_program()” method, specifically on line 47 of the file testprogramProgramNodeContribution. So look for any variables you’ve created that are using some .methodCall() on that particular line that you haven’t initialized.
