From 65a0f467ae835cc5680328ad37e170e8f0cd19ae Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Mon, 17 Apr 2023 21:33:56 +0200 Subject: [PATCH] Native libraries: Fixed `IllegalArgumentException: URI scheme is not "file"` when using FlatLaf in WebStart. (issue #668; regression in FlatLaf 3.1) --- CHANGELOG.md | 2 ++ .../java/com/formdev/flatlaf/ui/FlatNativeLibrary.java | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a90058ab7..ea3a9c3e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ FlatLaf Change Log "Material Theme UI Lite" themes; issue #667; regression in FlatLaf 3.1). - Fixed too large tree row height in "Carbon", "Dark Purple", "Gray", "Material Design Dark", "Monokai Pro", "One Dark" and "Spacegray" themes. +- Native libraries: Fixed `IllegalArgumentException: URI scheme is not "file"` + when using FlatLaf in WebStart. (issue #668; regression in FlatLaf 3.1) ## 3.1 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLibrary.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLibrary.java index 7fef79b5d..f9daf4946 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLibrary.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLibrary.java @@ -18,6 +18,7 @@ import java.io.File; import java.net.URL; +import java.security.CodeSource; import com.formdev.flatlaf.FlatSystemProperties; import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.NativeLibrary; @@ -128,10 +129,15 @@ private static NativeLibrary createNativeLibrary( String classifier, String ext private static File findLibraryBesideJar( String classifier, String ext ) { try { // get location of FlatLaf jar - URL jarUrl = FlatNativeLibrary.class.getProtectionDomain().getCodeSource().getLocation(); + CodeSource codeSource = FlatNativeLibrary.class.getProtectionDomain().getCodeSource(); + URL jarUrl = (codeSource != null) ? codeSource.getLocation() : null; if( jarUrl == null ) return null; + // if url is not a file, then we're running in a special environment (e.g. WebStart) + if( !"file".equals( jarUrl.getProtocol() ) ) + return null; + File jarFile = new File( jarUrl.toURI() ); // if jarFile is a directory, then we're in a development environment