We are about to switch to a new forum software. Until then we have removed the registration on this forum.
There is not much code involved in the problem;
these are the imports; import processing.data.Table; import processing.data.TableRow;
The table
Table table;
this is the code causing the problem ; 'Exception in thread "Animation Thread" java.lang.NullPointerException"'
table = parent.loadTable("new.csv", "header");
No matter where I put the csv, the file is ignored/not seen, giving me a null pointer the classses are stored in the src pakage, I am not sure if this is the right place?
Any help would really really be appreciated!
Answers
Do I understand correctly that a NullPointerException is thrown on that exact line, with the code
table = parent.loadTable("new.csv", "header");
?Because if so, then your program probably doesn't even get to loading the .csv file.
The only way a NullPointerException can be thrown on that line is if
parent
isnull
. What happens if you print the value ofparent
?println(parent);
Thx for the reaction!
I checked it, and indeed, the print shows a null, but this is strange since I wrote
parent.println("Value " + parent + "")
;If parent is null, how then can I use the println keyword in Intelij?? if its null, println should not be recognized in the first place, what am I missing here?
static
methods.null
, that is completely ignored by Java.static
. Thus it is stateless and doesn't care about references.static
or not, reside within their original class, not in some object of it.static
fields also live inside classes. Objects only got non-static
fields within them.Something's off... you're right that it should not be possible to call
parent.println()
if parent is null.As little code as there may be, please do post it so we can see the whole picture. I think Intellij's compile routine is playing a mean trick, where the code it uses is not the same as the one you see.
That has happened to me, before, so I wouldn't be surprised.
EDIT: Nevermind. Code is not necessary, after GoToLoop reminded me how Java worked in that manner.
Okay, that is why one works, and not the other, there us probably something wrong in the order of the commands given, I'l look into that. I'll keep you both updated :)
@GoToLoop
Oh... yeah, I forgot about Java ignoring whether or not a variable is initialized or not if the method is static.
I haven't done too much Processing programming in Java IDEs, but if he's having trouble with the loadTable method, then does that make it a non-static method?
I don't see any other way his code could be throwing a NullPointerException, unless the Processing's library code doesn't have error handling for a case such as this (which I highly doubt).
static
.static
method main() or runSketch() in order to have an actual functioning instance of it.static
it still needs some PApplet reference regardless.new PApplet().loadTable("new.csv", "header");
.try / catch ()
block for P3. While P2 & P1 works:I got it fixed, thank you guys, it was the weird PApplet behavior thet threw me off, made me to miss interpret ate the errors. Anyway, the reason why it didnt worked was because something was missing, the PApplet (here named parent) was not given to the class which needed it!, so evidently it was a null!
Anyway, you two were of tremendous help, made me able to put two and two together!