• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

a very primitive problem

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,
the file Example1.java compiles okay, but it won't run. I included the jar files in the classpath and i cant understand why it won't run.
Thanks.

code:





Error:
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Example1.class belongs to a package "net.sourceforge.jpcap.tutorial.example1". You have to run it as



That's how the .class file belonging to the package is stored and identified.
 
Moeness Baradei
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.. now i am getting this:

 
Bartender
Posts: 2265
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why java twice?

java java
 
Sheriff
Posts: 9674
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if you write a single java, the java command will only succeed if the .class file is in the correct directory. Is the Example1.class file in the correct directory structure?? It should be in the following directory structure

net/sourceforge/jpcap/tutorial/example1/Example1.class

This depends on how you compiled your program...
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply, where is your Example1.class file located? It should be in the folder structure/hierarchy matching with your package hierarchy as explained above.
 
Moeness Baradei
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[code]
// $Id: Example2.java,v 1.3 2002/02/18 15:33:00 pcharles Exp $

/***************************************************************************
* Copyright (C) 2001, Patrick Charles and Jonas Lehmann *
* Distributed under the Mozilla Public License *
* http://www.mozilla.org/NPL/MPL-1.1.txt *
***************************************************************************/

package net.sourceforge.jpcap.tutorial.example2;

import net.sourceforge.jpcap.capture.*;
import net.sourceforge.jpcap.net.*;


/**
* jpcap Tutorial - Example 2
*
* @author Jonas Lehmann and Patrick Charles
* @version $Revision: 1.3 $
* @lastModifiedBy $Author: pcharles $
* @lastModifiedAt $Date: 2002/02/18 15:33:00 $
*/
public class Example2
{
private static final int INFINITE = -1;
private static final int PACKET_COUNT = 10;

// BPF filter for capturing any packet
private static final String FILTER = "";

private PacketCapture m_pcap;
private String m_device;

public Example2() throws Exception {
// Step 1: Instantiate Capturing Engine
m_pcap = new PacketCapture();

// Step 2: Check for devices
m_device = m_pcap.findDevice();

// Step 3: Open Device for Capturing (requires root)
m_pcap.open(m_device, true);

// Step 4: Add a BPF Filter (see tcpdump documentation)
m_pcap.setFilter(FILTER, true);

// Step 5: Register a Listener for Raw Packets
m_pcap.addRawPacketListener(new RawPacketHandler());

// Step 6: Capture Data (max. PACKET_COUNT packets)
m_pcap.capture(PACKET_COUNT);
}

public static void main(String[] args) {
try {
Example2 example = new Example2();
} catch(Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}


class RawPacketHandler implements RawPacketListener
{
private static int m_counter = 0;

public void rawPacketArrived(RawPacket data) {
m_counter++;
System.out.println("Packet " + m_counter + "\n" + data + "\n");
}
}
[/code]
 
Ranch Hand
Posts: 95
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

Is the problem solved?

If not, did you compiled the source?
 
Moeness Baradei
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well Thanks
The problem is now solved.. I overcame the UnsatisfactoryLinkError by loading the DLL in the code using
System.load("jpcap.dll");

I do have a question at this point:
This is the first time that i know that java can use DLLs, does that make programs that use a dll not work in linux ?
Another thing is, can I load a JAR using the same way??

thanks a lot to everyone who answered.
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Moeness Baradei wrote:This is the first time that i know that java can use DLLs, does that make programs that use a dll not work in linux ?
Another thing is, can I load a JAR using the same way??


If you are speaking of native DLLs then yes it will not work on Linux.

There is no need to load a JAR, just include it in the classpath, thats all.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic