In general, I want to create a launcher for my project in minecraft. I want to launch my project, and after that the launcher should open, but it will not open. The reason for this is written down below (highlighted in red). Translated this matter on the Internet, but did not really understand what the problem was. Maybe someone knows and understands this? Help me please
Closed due to the fact that off-topic participants 0xdb , default locale , Nick Volynkin ♦ Jul 26 '18 at 10:16 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - 0xdb, default locale, Nick Volynkin
1 answer
When you load, you get a NullPointerException error and it occurs on the 31st line of the MainClass.jave file. This means that on this line there is a manipulation of an object that is null .
On this line you have written
stream.close(); 99% that stream is null . Accordingly, an attempt to call a method on null leads to an exception.
The stream variable is initialized on line 19
InputStream stream = Starter.class.getResourceAsStream("/net/launcher/theme/favivon.png"); The documentation for the getResourceAsStream() method says
Returns:
A InputStream object or null if not found
Or in translation
Returns:
An InputStream object or null if a resource with this name is not found.
Here is the answer.
- The program did not find the resource
/net/launcher/theme/favivon.png - You did not immediately check the result
- You received a
NullPointerExceptionwhen you tried to access the object
- Hmm, thank you :) And how to solve this problem? The fact is that I rummaged through the folders and found this resource favicon.png (the resource that the program could not find) - Daniel
- I solved the problem, thank you very much for your help, patience and understanding :)))) - Daniel
- @ Daniel Then mark my answer as correct - Anton Shchyrov


MainClass.java- Anton ShchyrovMainClass.javafileMainClass.javago to line 31 and see the error because of that - Anton Shchyrov