Skip to content
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

Runing on the a linux service reports a null pointer exception #309

Open
asdf101221 opened this issue Sep 7, 2023 · 0 comments
Open

Runing on the a linux service reports a null pointer exception #309

asdf101221 opened this issue Sep 7, 2023 · 0 comments

Comments

@asdf101221
Copy link

asdf101221 commented Sep 7, 2023

I installed libcap in linux and runed pcap4j . but program report path is null point exception
so I fixed it by modifying the org/pcap4j/core/NativeMappings.java file details as follows:
45 line
static final File NPCAP_DIR =
Paths.get(System.getenv("SystemRoot"), "System32", "Npcap").toFile();

Because System.getenv("SystemRoot") is null when programmer runing on linux.
So I change the code as follows:
static File NPCAP_DIR;

static {
LOG.info("NPCAP_DIR: "+ NativeMappings.NPCAP_DIR);
String evn = System.getenv("SystemRoot");
LOG.info("NPCAP_DIR evn: "+ evn);
if(evn!=null) {
Path path = Paths.get(System.getenv("SystemRoot"), "System32", "Npcap");
if(path!=null ) {
LOG.info("NPCAP_DIR: "+ path.getFileName());
NPCAP_DIR = path.toFile();
}else {
LOG.info("NPCAP_DIR IS NULL");
}
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant