From 6068d5a26095c7279363b56acbf8aeb745580a6e Mon Sep 17 00:00:00 2001 From: Andrew Auclair Date: Sun, 3 Dec 2023 22:35:19 -0500 Subject: [PATCH] Move NPCAP_DIR to if block. --- jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java b/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java index f2332ffd..543b47fe 100644 --- a/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java +++ b/jdk7/src/main/java/pcap/jdk7/internal/NativeMappings.java @@ -62,10 +62,12 @@ class NativeMappings { new HashMap(); static { - File NPCAP_DIR = Paths.get(System.getenv("SystemRoot"), "System32", "Npcap").toFile(); + if (Platform.isWindows() && System.getProperty("jna.library.path") == null) { + File NPCAP_DIR = Paths.get(System.getenv("SystemRoot"), "System32", "Npcap").toFile(); - if (Platform.isWindows() && System.getProperty("jna.library.path") == null && NPCAP_DIR.exists()) { - NativeLibrary.addSearchPath("wpcap", NPCAP_DIR.getAbsolutePath()); + if (NPCAP_DIR.exists()) { + NativeLibrary.addSearchPath("wpcap", NPCAP_DIR.getAbsolutePath()); + } } }