aspose file tools*
The moose likes Beginning Java and the fly likes a very primitive problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "a very primitive problem" Watch "a very primitive problem" New topic
Author

a very primitive problem

Moeness Baradei
Greenhorn

Joined: Jan 11, 2009
Posts: 12
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:
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

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.


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Moeness Baradei
Greenhorn

Joined: Jan 11, 2009
Posts: 12
Thanks for your reply.. now i am getting this:

Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

why java twice?

java java


Swastik
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

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

Joined: Jan 11, 2009
Posts: 12
[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]
Andre Brito
Ranch Hand

Joined: Dec 13, 2007
Posts: 95

Hi.

Is the problem solved?

If not, did you compiled the source?
Moeness Baradei
Greenhorn

Joined: Jan 11, 2009
Posts: 12
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.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

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.

SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a very primitive problem