Null Pointer Exception: why??
in
Core Library Questions
•
10 months ago
Here is a sketch that originally didn't have 'noLoop()' within setup, so that it repeatedly was sending a few characters to the serial port. But I need a single loop, so I added 'noLoop' in the setup function. And it stopped working!! Now though I delete it the sketch results wrong.
Why do I get a Null Pointer Exception at line #14??
Why do I get a Null Pointer Exception at line #14??
- import processing.serial.*;
- Serial serial;
- // =======================================================
- void setup() {
- int serialPortNumber = 0;
- println(Serial.list());
- String port = Serial.list()[serialPortNumber];
- noLoop();
- }
- //========================================================
- void draw () {
- char NL='\n';
- String lines[] = loadStrings ("Plotter_2.txt");
- for (int i=0 ; i < lines.length ; i++) {
- serial.write (lines[i]);
- serial.write(NL);
- println(lines[i]);
- }
- println("--------");
- }
I can't export the error message so I'm copying it:
Exception in thread "Animation Thread"
java.lang.NullPointerException
at Plotter_2.draw (Plotter_2.java:39)
at processing.core.PApplet.handleDraw(PApplet.java:2128)
at processing.core.PGraphicsJava2D.requestDraw(PGraphincsJava2D.java:190)
at processing.core.PApplet.run(PApplet.java:2006)
at java.lang.Thread.run(Thread.java:662)
That's all.
Thank you, bye.
Exception in thread "Animation Thread"
java.lang.NullPointerException
at Plotter_2.draw (Plotter_2.java:39)
at processing.core.PApplet.handleDraw(PApplet.java:2128)
at processing.core.PGraphicsJava2D.requestDraw(PGraphincsJava2D.java:190)
at processing.core.PApplet.run(PApplet.java:2006)
at java.lang.Thread.run(Thread.java:662)
That's all.
Thank you, bye.
1