在做个抓包+分析的简单软件,图形用户界面能出来了,但是一按“开始监听”就弹出了这一大串错:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no jpcap 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 jpcap.Jpcap.<clinit>(Jpcap.java:151)
at gui.ListenBegin.<init>(ListenBegin.java:20)
at gui.ListenBegin.getJpcap(ListenBegin.java:143)
at gui.JCaptor.capturePacketsFromDevice(JCaptor.java:89)
at gui.UserInterface.actionPerformed(UserInterface.java:217)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
从字面上看是找不到jpcap库,可是我已经把wincap装上了,jpcap.jar、jpcap.dll也放对位置了,怎么会这样。。

解决方案 »

  1.   

    要把那些DLL文件所在目录加到PATH环境变量中。
      

  2.   

    图形用户界面的代码太长,大部分是为了粉饰用的,所以只截取了被中断的进程的方法的代码这是按了“开始监听”按钮后弹出的设置对话框,功能是设置抓取报文的长度和过滤
    public void actionPerformed(ActionEvent e)
    { String cmd = e.getActionCommand();
    if(cmd.equals("Whole"))
    { caplenField.setText("2048");
    caplenField.setEnabled(false);
    }
    else if(cmd.equals("Head"))
    { caplenField.setText("68");
    caplenField.setEnabled(false);
    }
    else if(cmd.equals("Other"))
    { caplenField.setText("");
    caplenField.setEnabled(true);
    caplenField.requestFocus();
    }
    else if(cmd.equals("OK"))
    { try{ int caplen = Integer.parseInt(caplenField.getText());
    if(caplen<68 || caplen>2048)
    { JOptionPane.showMessageDialog(null, "数据包长度应在68字节和2048字节之间");
    return;
    }
    jpcap = Jpcap.openDevice(devices[adapterChoose.getSelectedIndex()], caplen, promiscCheck.isSelected(), 50);
    if(filterField.getText()!=null && filterField.getText().length()>0){
    jpcap.setFilter(filterField.getText(),true);
    }
    }catch(NumberFormatException e1){
    JOptionPane.showMessageDialog(null, "请输入合法的数据包长度");
    }catch(java.io.IOException e1){
    JOptionPane.showMessageDialog(null, e1.toString());
    }finally{ dispose();
    }
    }
    else if(cmd.equals("Cancel"))
    { dispose();
    }
    } public static Jpcap getJpcap(UserInterface parent){
    new ListenBegin(parent).setVisible(true);
    return jpcap;
    }
      

  3.   

    我用MyEclipse做开发工具的,是写在.classpath文件下么?
      

  4.   

    我在环境变量中设置path:g:/jdk1.6/bin,把jpcap.dll也塞了进去,可是问题依旧
      

  5.   

    我debug了下,把两个中断点都取消了,继续运行,结果出现了source not found
      

  6.   

    是写在.classpath文件同目录下的。。还有你的wincap安装了没。。
      

  7.   

    装了。。
    .classpath文件里的,是这样的么?
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry kind="lib" path="G:/java/jre/lib/ext/jpcap.jar"/>
    <classpathentry kind="output" path="bin"/>
    </classpath>
      

  8.   

    知道原因了,是没把jpcap.dll文件拷到system32下,并且jpcap.jar和wincap版本不兼容
      

  9.   

    一定要装wincap吗,jpcap.jar、jpcap.dll这些文件在哪里找,能说细一点么,我刚也遇到了这样的问题,还没解决呢,,,,