diff --git a/opus-jni-java/src/main/java/net/labymod/opus/OpusCodec.java b/opus-jni-java/src/main/java/net/labymod/opus/OpusCodec.java index 60b5d83..055a7b1 100644 --- a/opus-jni-java/src/main/java/net/labymod/opus/OpusCodec.java +++ b/opus-jni-java/src/main/java/net/labymod/opus/OpusCodec.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.file.AccessDeniedException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; @@ -278,7 +279,11 @@ public static void loadNative(File directory, boolean allowArm) throws IOExcepti } Path destination = directory.toPath().resolve(nativeLibraryName); - Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING); + try { + Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING); + } catch (AccessDeniedException ignored) { + // The file already exists, or we don't have permission to write to the directory + } System.load(new File(directory, nativeLibraryName).getAbsolutePath()); }