lwjglgamedev / lwjglbook-leg

Source code of the chapters of the book 3D Game Development with LWJGL 3
https://ahbejarano.gitbook.io/lwjglgamedev/
Apache License 2.0
560 stars 202 forks source link

NullPointerException at Scanner constructor #19

Closed espacotempo closed 7 years ago

espacotempo commented 7 years ago

Hi, I'm facing a NullPointerException in the Utils.java line 11 (chapter 4 forward), when it try to instantiate the Scanner. The file of the string 'fileName' is ok. LOG: vertex.vs is a true file (my print) java.lang.NullPointerException: source at java.util.Objects.requireNonNull(Objects.java:228) at java.util.Scanner.(Scanner.java:578) at org.lwjglb.engine.Utils.loadResource(Utils.java:11) at org.lwjglb.game.Renderer.init(Renderer.java:26) at org.lwjglb.game.DummyGame.init(DummyGame.java:22) at org.lwjglb.engine.GameEngine.init(GameEngine.java:50) at org.lwjglb.engine.GameEngine.run(GameEngine.java:38) at java.lang.Thread.run(Thread.java:745)

lwjglgamedev commented 7 years ago

I will check this as soon as possible.

espacotempo commented 7 years ago

I'm trying to fix it. But nothing for now. Thanks

lwjglgamedev commented 7 years ago

I've just checked it and I'm able to execute it with no problem. The exception you get is because the InputStream that points to the file is null. That mens that the file cannot be loaded from the CLASSPATH. Are you executing the sample inside Netbens? If not, please tell me which IDE are you using.

In any case, try to add to the CLASSPATH the resources folder.

espacotempo commented 7 years ago

I'm executing the sample inside Eclipse.

espacotempo commented 7 years ago

I have added the resources folder to the class folder and it worked. Thank you very much.

schmalexandre commented 7 years ago

Which class folder did you add the resources folder to? I'm having the same issue.

lwjglgamedev commented 7 years ago

The folder named "resources".

AndyKrause95 commented 6 years ago

Same issue... where exactly do I put the resource folder within Eclipse? Can't really get this figured out. Someone walk me through the steps please

lwjglgamedev commented 6 years ago

The easy way, just import the samples for each chapter as a maven project. For instance, for chapter28. In eclipse:

If you still experience problems, please let me know.