-
-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library does not initialise on Linux #308
Comments
@vgaj use |
2.0.0-alpha.6 have null point exception prablem to linux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using the library on Linux it fails to start up with the following exception:
Caused by: java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:209)
at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:263)
at java.base/java.nio.file.Path.of(Path.java:147)
at java.base/java.nio.file.Paths.get(Paths.java:69)
at org.pcap4j.core.NativeMappings.(NativeMappings.java:46)
I was using the library via Maven dependency
org.pcap4j
pcap4j-core
2.0.0-alpha.6
Looking at the code we can see that it's trying to use an environment variable called "SystemRoot" which won't exist when running on Linux.
static final File NPCAP_DIR =
Paths.get(System.getenv("SystemRoot"), "System32", "Npcap").toFile();
To work around the problem all you need to do is to define the environment variable before starting the application using the library. So there is an easy work around.
export SystemRoot=""
However updating the code with a Platform.isWindows() check will avoid having to do this.
The text was updated successfully, but these errors were encountered: