Could not load JIntellitype.dll from local file system or from inside JAR

2k views Asked by At

I am trying to use JIntellitype to listen to global hotkeys but I get this error:

Exception in thread "main" com.melloware.jintellitype.JIntellitypeException: Could not load JIntellitype.dll from local file system or from inside JAR at com.melloware.jintellitype.JIntellitype.(JIntellitype.java:114) at com.melloware.jintellitype.JIntellitype.getInstance(JIntellitype.java:177) at utils.HotKey.(HotKey.java:19) at ui.Main.Catch_Hotkeys(Main.java:78) at ui.Main.(Main.java:20) at ui.Main.main(Main.java:15) Caused by: java.io.IOException: FromJarToFileSystem could not load DLL: com/melloware/jintellitype/JIntellitype.dll at com.melloware.jintellitype.JIntellitype.fromJarToFs(JIntellitype.java:150) at com.melloware.jintellitype.JIntellitype.(JIntellitype.java:105) ... 5 more Caused by: java.lang.NullPointerException at com.melloware.jintellitype.JIntellitype.fromJarToFs(JIntellitype.java:146) ... 6 more

I have loaded the jar file and I also pointed to the folder where the dlls are located through Referenced Libraries.

Here is the code I am trying to run:

import com.melloware.jintellitype.HotkeyListener;
import com.melloware.jintellitype.IntellitypeListener;
import com.melloware.jintellitype.JIntellitype;

public class HotKey extends Thread implements HotkeyListener, IntellitypeListener {

    private final int CTRL_C_SHIFT = 10;

    public HotKey()
    {
      JIntellitype.getInstance().unregisterHotKey(CTRL_C_SHIFT);
      JIntellitype.getInstance().registerHotKey(CTRL_C_SHIFT, JIntellitype.MOD_CONTROL  + (int)'C',  JIntellitype.MOD_SHIFT);

      if (!JIntellitype.isJIntellitypeSupported()) 
      {
         System.exit(1);
      }
    }

    @Override
    public void onIntellitype(int arg0) 
    {

    }

    @Override
    public void onHotKey(int key) 
    {
         if (key == CTRL_C_SHIFT)
         {
             System.out.println("smg");
         }
    }


}  

Any idea how to fix this?

2

There are 2 answers

0
hfontanez On

I recommend you do something like this:

     try
     {
        JIntellitype.getInstance().unregisterHotKey(CTRL_C_SHIFT);
        MyHotKeyListener hotKeyListener = new MyHotKeyListener();
        hotKeyListener.addObserver(new MyEventListener());
        JIntellitype.getInstance().addHotKeyListener(hotKeyListener);
        JIntellitype.getInstance().registerHotKey(CTRL_C_SHIFT, JIntellitype.MOD_CONTROL  + (int)'C',  JIntellitype.MOD_SHIFT);
     }
     catch (JIntellitypeException je)
     {
        logger.warn("JIntellitype initialization failed.");
        // DO WHATEVER (NOTIFY USERS?)
     }

I can point to other threads, including one where the creator of this library himself denies problems with the library. However, many users such as myself encounter these sort of problems from time to time where JIntellitype fails to initialize and the only solution is to reboot the computer. Because of this, you should catch the JIntellitype exception (the only exception thrown by the library) and warn users (via dialog window) that the hotkey failed to register. You should give them the option to continue without them, or to reboot the computer and trying again.

Trust me.... unless this is a constant problem (which means you configured it incorrectly), it is your best alternative. This WILL happen from time to time at random.

1
have nice day On

Your problem will occur because of a version problem between that OS version and the JRE version.

You should check:

  1. Whether an appropriate dll file is installed in your OS system folder. JIntellitype package has two dll files, one is for 32bit OSs and the other is for 64bit OSs, they have different names.

  2. Check your Java Platform version in the properties of the projects. You can try to change the Java Platform, if there are more than one types of JDKs. Make sure about which one is for 64bit or 32bit version.

Have good luck!