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?
I recommend you do something like this:
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.