【问题标题】:networkinterface in linux undetectedlinux中的网络接口未被检测到
【发布时间】:2013-02-16 23:42:54
【问题描述】:

我已经尝试了以下代码:

NetworkInterface[] devices = JpcapCaptor.getDeviceList();
    JpcapCaptor jpcap = null;
    System.out.print(devices.length);
    for (int a=0;a<devices.length;a++)
    {
        try
        {
            jpcap = JpcapCaptor.openDevice(devices[a], 2000, true, 20);
            jpcap.loopPacket(-1, new arp_spoofing());//for capture packet
        } 
        catch (IOException ex) 
        {
            Logger.getLogger(Receiver2.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

在相同的代码中。当我在 Windows 中运行时,我得到了一些界面,但在 linux 中我没有得到任何界面.. 没有语法错误..

【问题讨论】:

标签: java linux windows network-programming network-interface


【解决方案1】:

我在 Ubuntu 11.10 和 netbeans 中运行时遇到了同样的问题。当我尝试使用终端(具有 sudo 权限)运行 jar 文件时,它起作用了。我认为问题在于 linux 中的权限。

尝试在终端sudo java -jar YourJarFile.jar运行.jar文件

【讨论】:

    【解决方案2】:

    这可能是 Linux 无法检测到该接口,因此它也不适用于任何 Java 程序。运行以下命令会得到什么?

    sudo ifconfig 
    

    将其添加到问题中,以便更容易诊断问题。这里有一个相关的问题,在 Unix/Linux StackExchange 上:

    https://unix.stackexchange.com/questions/48980/cannot-get-realtek-r8168-ethernet-card-up/52451#52451

    【讨论】:

    • 当我运行该命令时,我得到 4 个设备:eth0、eth1、lo 和 wlan0
    • 他们是否分配了 IP 地址?
    • 你添加了'ifconfig'输出了吗??
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-03
    • 2015-12-09
    • 2016-09-19
    • 2014-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多