# Using system time functions causes sketch to not run? ("Target VM failed to initialize")

**URL:** <https://discourse.processing.org/t/using-system-time-functions-causes-sketch-to-not-run-target-vm-failed-to-initialize/40597>\
**Category:** Beginners\
**Created:** [January 15, 2023, 2:09am UTC](https://discourse.processing.org/t/using-system-time-functions-causes-sketch-to-not-run-target-vm-failed-to-initialize/40597 "2023-01-15T02:09:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stetez14](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stetez14](https://discourse.processing.org/u/Stetez14)\
**Post date:** [January 15, 2023, 2:09am UTC](https://discourse.processing.org/t/using-system-time-functions-causes-sketch-to-not-run-target-vm-failed-to-initialize/40597/1 "2023-01-15T02:09:12Z")

</div>

I’m not sure if this is the correct forum, but I seem to have encountered a major issue in my project. My sketch has started fine so far but suddenly stopped working. Through some basic troubleshooting, I found  
the issue is related to any-and-all system time functions (I.E hour(), minute(), and second()). I also tried writing the functions in the exact syntax shown in the documentation, to no avail. Please help if you can. Here’s my code, i’ve included the entirety of the draw function for clarity:

```auto
void draw() { 
  
  Current_Time[0] = hour();
  
  // Current_Time[1] = minute();
  
  // Current_Time[2] = second();
  
  

  if (AI_Output != null) {
    
    Output_Alpha = 0;
    
    ShowOutput();
    
  }

  // Initialzation:
  
  if (Splash_Frame < 240) {
    
    Splash_Frame += 1;
    
    Splash_Boot();
    
    print(Splash_Frame, " ");
    
  } else {
    
    Nora_Boot();
        
    // Nora Sign:
    
    textAlign(LEFT);
    
    Absolute_Text_Size = (float(height) / float(displayHeight)) * 100;
      
    textSize(int(Absolute_Text_Size));
    
    fill(255, 255, 255, 255 - Boot_Fade * 2);
  
    text("NORA", 20, (float(height) / float(displayHeight)) * 110);
    
    
    // Response Query:
      
    textSize(int(Absolute_Text_Size * .55)); 
    
    fill(255,60,180,Output_Alpha);

    textLeading(25);
    
    textAlign(CENTER, CENTER);
    
    text(Finished_Output, 20, (float(height) / float(displayHeight)) * 200, width * .8746, height * .625);

    
    // Initialization Frame 1:

    if (Initialize_Frame == 1) {
      
      surface.setTitle("Nora, Your Virtual Companion.");
  
      surface.setResizable(false);

      surface.setLocation(int(displayWidth * .825), int(displayHeight * .56));
      
      surface.setAlwaysOnTop(true);      
      
    }
    
  }
  
}

```

---

<div class="post-metadata">

**Author:** ![Stetez14](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stetez14](https://discourse.processing.org/u/Stetez14)\
**Post date:** [January 15, 2023, 2:33am UTC](https://discourse.processing.org/t/using-system-time-functions-causes-sketch-to-not-run-target-vm-failed-to-initialize/40597/3 "2023-01-15T02:33:45Z")

</div>

After some more digging, turns out the problem is caused by a simple “Null Pointer Exception”, the VM error was clearly due to an internal mix-up, caused by such an error at runtime, apparently using `int[]` does not form a table after all…

---

<div class="post-metadata">

**Author:** ![Stetez14](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stetez14](https://discourse.processing.org/u/Stetez14)\
**Post date:** [January 15, 2023, 2:41am UTC](https://discourse.processing.org/t/using-system-time-functions-causes-sketch-to-not-run-target-vm-failed-to-initialize/40597/4 "2023-01-15T02:41:54Z")

</div>

I created a separate sketch to test my theory and I’m getting the same error, here’s my new code

```auto
IntList CurrentTime;

void draw() {
  
  CurrentTime.append(hour());
  
  print(CurrentTime);
  
}

```

---

<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 15, 2023, 3:24am UTC](https://discourse.processing.org/t/using-system-time-functions-causes-sketch-to-not-run-target-vm-failed-to-initialize/40597/5 "2023-01-15T03:24:05Z")

</div>

```auto
final IntList currentTime = new IntList();

void setup() {
  currentTime.append(hour());
  println(currentTime);
  exit();
}

```

You’ve skipped creating an IntList via operator `new`:

> **[new / Reference](https://processing.org/reference/new.html)**
>
> Creates a "new" object. The keyword new is typically used similarly to the applications in the above example. In this example, a new object "h1" of the datatype "HLine" is created. On the follo…

In Java merely declaring a non-primitive variable like this `IntList currentTime;` doesn’t automatically creates an object for it.

All declared non-primitive variables got a default value `null` if we skip initializing it:  
[Why do I get a NullPointerException?](https://forum.processing.org/two/discussion/8071/why-do-i-get-a-nullpointerexception.html)

---

<div class="post-metadata">

**Author:** ![Stetez14](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Stetez14](https://discourse.processing.org/u/Stetez14)\
**Post date:** [January 19, 2023, 6:37pm UTC](https://discourse.processing.org/t/using-system-time-functions-causes-sketch-to-not-run-target-vm-failed-to-initialize/40597/6 "2023-01-19T18:37:44Z")

</div>

Thanks, I’m still pretty new to java and processing so… 👍 Now I can continue my project. Also thanks for the helpful link and code, I’ll be able to keep this in mind for the future. 😀
