I have an issue reported by an user which I cannot reproduce. The issue is error:
Exception in thread "main" java.lang.NullPointerException: source
at java.util.Objects.requireNonNull(Unknown Source)
at java.util.Scanner.(Unknown Source)
at cz.autoclient.Main.getVersion(Main.java:86)
at cz.autoclient.Main.(Main.java:76)
at cz.autoclient.Main.main(Main.java:262)
In this code:
private VersionId VERSION = new VersionId("0.0-error");
public final VersionId getVersion() {
if(VERSION.affix.equals("error")) {
InputStream in = Main.class.getResourceAsStream("/version");
Scanner sc = new Scanner(in, "UTF-8"); // LINE 86
VERSION = new VersionId(sc.useDelimiter("\\A").next());
}
return VERSION;
}
What I do here is to parse internal resource which contains version info for the application (including version as variable turned out to be very impractical).
Version file might look something like this:
v3.5-beta
The error seems to be caused by the resource "/version"
being unreachable. This error does only seem to happen to the user, so I need help why it even might happen. User's Java version is:
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
Here is the full Main.java
(specific commit). The application is distributed as jar
file. The version
file is in the root of the jar file.
In case it happened to be unclear the problem is when I run the same release (downloaded from release site, not re-built), I do not encounter the problem. I asked the user to verify that the file is there (by unziping the jar file). He sent it to me, it was intact.