Skip to content

Commit 2a064a5

Browse files
committed
Pushing changes for new manifest approach that should solve the strange behavior on OSX.
1 parent 3a498b6 commit 2a064a5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/java/org/jnativehook/GlobalScreen.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.io.IOException;
3434
import java.io.InputStream;
3535
import java.math.BigInteger;
36+
import java.net.URL;
3637
import java.security.DigestInputStream;
3738
import java.security.MessageDigest;
3839
import java.security.NoSuchAlgorithmException;
@@ -41,6 +42,7 @@
4142
import java.util.concurrent.Executors;
4243
import java.util.concurrent.ThreadFactory;
4344
import java.util.jar.Attributes;
45+
import java.util.jar.JarInputStream;
4446
import java.util.jar.Manifest;
4547
import java.util.logging.Logger;
4648

@@ -521,12 +523,12 @@ private static void loadNativeLibrary() {
521523
if (libInputStream != null) {
522524
try {
523525
// Try and load the Jar manifest as a resource stream.
524-
InputStream manInputStream = GlobalScreen.class.getResourceAsStream("/META-INF/MANIFEST.MF");
525-
if (manInputStream != null) {
526-
// Try and extract a version string from the Manifest.
527-
Manifest manifest = new Manifest(manInputStream);
526+
URL jarFile = GlobalScreen.class.getProtectionDomain().getCodeSource().getLocation();
527+
JarInputStream jarInputStream = new JarInputStream(jarFile.openStream());
528528

529-
// FIXME More OS X JRE Bugs! This returns NULL but only for Apple!
529+
// Try and extract a version string from the Manifest.
530+
Manifest manifest = jarInputStream.getManifest();
531+
if (manifest != null) {
530532
Attributes attributes = manifest.getAttributes(basePackage);
531533

532534
if (attributes != null) {

0 commit comments

Comments
 (0)