在做个抓包+分析的简单软件,图形用户界面能出来了,但是一按“开始监听”就弹出了这一大串错:
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也放对位置了,怎么会这样。。
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也放对位置了,怎么会这样。。
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;
}
.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>