原帖:http://topic.csdn.net/u/20090327/15/933cf668-8bca-411f-8b82-18c49772a537.html
参考文章:http://walsece.javaeye.com/blog/191169我下载了jintellitype-1.3.1.jar后,把JIntellitype.dll复制到了C:\WINDOWS\system32下,然后在eclipse工程名在点击右键——属性——Java构建路径——库——添加外部jar,然后把jintellitype-1.3.1.jar添加到工程中,编译后还是发生错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.melloware.jintellitype.JIntellitype.<clinit>(JIntellitype.java:57)
at HotKey.initHotkey(HotKey.java:45)
at HotKey.main(HotKey.java:57)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 3 more请高手指教!!!!!!!!!!!!!!!!!!!!!!!!!!谢谢!import com.melloware.jintellitype.HotkeyListener;
import com.melloware.jintellitype.JIntellitype;
public class HotKey implements HotkeyListener {
static final int KEY_1 = 88;
static final int KEY_2 = 89;
static final int KEY_3 = 90;
/**
* 该方法负责监听注册的系统热键事件
*
* @param key:触发的热键标识
*/
public void onHotKey(int key) {
switch (key) {
case KEY_1:
System.out.println("ctrl+alt+I 按下.........");
break;
case KEY_2:
System.out.println("ctrl+alt+O 按下.........");
break;
case KEY_3:
System.out.println("系统退出..........");
destroy();
}
}
/**
* 解除注册并退出
*/
void destroy() {
JIntellitype.getInstance().unregisterHotKey(KEY_1);
JIntellitype.getInstance().unregisterHotKey(KEY_2);
JIntellitype.getInstance().unregisterHotKey(KEY_3);
System.exit(0);
}
/**
* 初始化热键并注册监听事件
*/
void initHotkey() {
//参数KEY_1表示改组热键组合的标识,第二个参数表示组合键,如果没有则为0,该热键对应ctrl+alt+I
JIntellitype.getInstance().registerHotKey(KEY_1, JIntellitype.MOD_CONTROL + JIntellitype.MOD_ALT,
(int) 'I');
JIntellitype.getInstance().registerHotKey(KEY_2, JIntellitype.MOD_CONTROL + JIntellitype.MOD_ALT,
(int) 'O');
JIntellitype.getInstance().registerHotKey(KEY_3, JIntellitype.MOD_CONTROL + JIntellitype.MOD_ALT,
(int) 'X');
JIntellitype.getInstance().addHotKeyListener(this);
}
public static void main(String[] args) {
HotKey key = new HotKey();
key.initHotkey();
//下面模拟长时间执行的任务
while (true) {
try {
Thread.sleep(10000);
} catch (Exception ex) {
break;
}
}
}
}
参考文章:http://walsece.javaeye.com/blog/191169我下载了jintellitype-1.3.1.jar后,把JIntellitype.dll复制到了C:\WINDOWS\system32下,然后在eclipse工程名在点击右键——属性——Java构建路径——库——添加外部jar,然后把jintellitype-1.3.1.jar添加到工程中,编译后还是发生错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at com.melloware.jintellitype.JIntellitype.<clinit>(JIntellitype.java:57)
at HotKey.initHotkey(HotKey.java:45)
at HotKey.main(HotKey.java:57)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 3 more请高手指教!!!!!!!!!!!!!!!!!!!!!!!!!!谢谢!import com.melloware.jintellitype.HotkeyListener;
import com.melloware.jintellitype.JIntellitype;
public class HotKey implements HotkeyListener {
static final int KEY_1 = 88;
static final int KEY_2 = 89;
static final int KEY_3 = 90;
/**
* 该方法负责监听注册的系统热键事件
*
* @param key:触发的热键标识
*/
public void onHotKey(int key) {
switch (key) {
case KEY_1:
System.out.println("ctrl+alt+I 按下.........");
break;
case KEY_2:
System.out.println("ctrl+alt+O 按下.........");
break;
case KEY_3:
System.out.println("系统退出..........");
destroy();
}
}
/**
* 解除注册并退出
*/
void destroy() {
JIntellitype.getInstance().unregisterHotKey(KEY_1);
JIntellitype.getInstance().unregisterHotKey(KEY_2);
JIntellitype.getInstance().unregisterHotKey(KEY_3);
System.exit(0);
}
/**
* 初始化热键并注册监听事件
*/
void initHotkey() {
//参数KEY_1表示改组热键组合的标识,第二个参数表示组合键,如果没有则为0,该热键对应ctrl+alt+I
JIntellitype.getInstance().registerHotKey(KEY_1, JIntellitype.MOD_CONTROL + JIntellitype.MOD_ALT,
(int) 'I');
JIntellitype.getInstance().registerHotKey(KEY_2, JIntellitype.MOD_CONTROL + JIntellitype.MOD_ALT,
(int) 'O');
JIntellitype.getInstance().registerHotKey(KEY_3, JIntellitype.MOD_CONTROL + JIntellitype.MOD_ALT,
(int) 'X');
JIntellitype.getInstance().addHotKeyListener(this);
}
public static void main(String[] args) {
HotKey key = new HotKey();
key.initHotkey();
//下面模拟长时间执行的任务
while (true) {
try {
Thread.sleep(10000);
} catch (Exception ex) {
break;
}
}
}
}
这个是因为apache的commons-logging的jar没导入
非常感谢,导入成功了,原来少了个文件,我的eclipse插件里没有,刚下载并导入了,可又出现异常了:信息: Loading JIntellitype DLL
Exception in thread "main" com.melloware.jintellitype.JIntellitypeException: java.lang.UnsatisfiedLinkError: no JIntellitype in java.library.path
at com.melloware.jintellitype.JIntellitype.<init>(JIntellitype.java:100)
at com.melloware.jintellitype.JIntellitype.getInstance(JIntellitype.java:122)Caused by: java.lang.UnsatisfiedLinkError: no JIntellitype in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.melloware.jintellitype.JIntellitype.<init>(JIntellitype.java:95)
... 4 more
我把JIntellitype.dll文件放到C:\WINDOWS\system32了,还在环境变量里的用户变量和系统变量都又增加了一个路径设置,都放了JIntellitype.dll文件,为什么还错误啊?
麻烦再帮我一下,如何设置java.library.path
我把把JIntellitype.dll文件放到C:\WINDOWS\system32,根本不行,放到D:\Program Files\Java\jre6\bin中,才有作用,我如何自己设置java.library.path ???
谢谢!