原帖: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;   
            }   
        }   
    }   

解决方案 »

  1.   

    initHotkey()方法中的JIntellitype.getInstance().registerHotKey(KEY_1, JIntellitype.MOD_CONTROL + JIntellitype.MOD_ALT,(int) 'I');  发生错误!
      

  2.   

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory 
    这个是因为apache的commons-logging的jar没导入
      

  3.   

    你可以去apache官方网站下载,如果你用的ide是eclipse的话,它的plugins目录里也有这个包
      

  4.   

    我用的是eclipse,应该导入成功了,我在没有导入之前,全都是错误,无法解析,包导入错误,导入包之后,全部正确,就是在编译的时候,发生了错误,也把JIntellitype.dll 放到Windows/System32了 
      

  5.   

    然后在eclipse工程名在点击右键——属性——Java构建路径——库——添加外部jar,然后把commons-logging.jar添加到工程中这个jar包可以上apache网站上下
      

  6.   

    Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory 缺少这个 commons-loggins.jar类库,我这里有http://www.java2000.net/download/jar.jsp?filename=&pre=c

      

  7.   


    非常感谢,导入成功了,原来少了个文件,我的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文件,为什么还错误啊?
      

  8.   

    现在基本问题都解决了,可以运行了,非常感谢大家
    麻烦再帮我一下,如何设置java.library.path 
    我把把JIntellitype.dll文件放到C:\WINDOWS\system32,根本不行,放到D:\Program Files\Java\jre6\bin中,才有作用,我如何自己设置java.library.path ???
    谢谢!
      

  9.   

    关注中,楼主确实很细心,在看到这个帖子以前我遇到的问题和楼主的一样。其他的地方贴的都是没有解决问题。还是csdn好呀
      

  10.   

    用System.setProperty设置java.library.path 
      

  11.   

    D:\Program Files\Java\jre6\bin  这个目录是你的CLASSPATH吧!那么你在你的CLASSPATH里加入别的路径就可以了吧,例如把JIntellitype.dll所在的文件夹加入CLASSPATH