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?
Your problem will occur because of a version problem between that OS version and the JRE version.
You should check:
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.
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!