Link to home
Start Free TrialLog in
Avatar of keviin55
keviin55

asked on

problem running java program

Hello,


I developed a java program with eclipse that has a graphical interface. During the execution of program when I click a button I have the following message that appears:

FATAL: could not find file 'simulator.properties' in default search paths:
'null', 'C:\Users\.../properties'

this is the code :
import net.sourceforge.jpcap.simulator.PacketCaptureSimulator;
import net.sourceforge.jpcap.capture.*;
import net.sourceforge.jpcap.net.*;

import java.awt.*;
import java.awt.event.*;

import java.io.*;

import java.util.*;

import javax.swing.table.*;
import javax.swing.*;

import java.util.*;
public class FB extends JFrame implements ActionListener {
private JButton b;
private TablePanel tablePanel;

public void actionPerformed(java.awt.event.ActionEvent e) {
new Packets().simulate();
}

private void setGui() {
try {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Container cp = getContentPane();
JPanel bPanel = new JPanel();
tablePanel = new TablePanel();
b = new JButton("Afficher");
b.addActionListener(this);
bPanel.add(b);
cp.add(tablePanel, BorderLayout.CENTER);
cp.add(bPanel, BorderLayout.SOUTH);
} catch (Exception e) {
e.printStackTrace();
}
}

private class Packets {

public void simulate() {
try {
PacketCaptureSimulator sim = new PacketCaptureSimulator();
sim.addPacketListener(tablePanel);
sim.capture(256);
sim.close();
}
catch(Exception e) {
e.printStackTrace();
}
}
}


public static void main(String[] args) {
	try {
	SwingUtilities.invokeAndWait(new Runnable() {
	public void run() {
	FB f = new FB();
	f.setGui();
	f.pack();
	f.setVisible(true);

	}
	});
	} catch (Exception e) {
	e.printStackTrace();
	}
	
	}
	

	private class TablePanel extends JPanel implements PacketListener {
	/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
	JTable table;
	Object[] headers = {
	"Adresse IP source",
	"Adresse IP destination",
	"Data",
	"Protocol"
	};

	public TablePanel() {
	table = new JTable(new DefaultTableModel(null, headers));
	add(new JScrollPane(table));
	}

	public void packetArrived(Packet packet) {
		try {
		
			
		if (packet instanceof IPPacket) {
	IPPacket ip = (IPPacket)packet;
	
	String[] data = new String[] {
	ip.getSourceAddress(),
	ip.getDestinationAddress(),
	new String(ip.getData()),
	IPProtocol.getDescription(ip.getIPProtocol())
	};
	updateTable(data);
		}
		
		
		if (packet instanceof EthernetPacket) {
			EthernetPacket ethernetPacket = (EthernetPacket) packet;
			String[] data = new String[] {
			ethernetPacket.getSourceHwAddress(),ethernetPacket.getDestinationHwAddress()};
			}

			
		if (packet instanceof ARPPacket) {
				ARPPacket arpPacket = (ARPPacket) packet;
				String[] data = new String[] {arpPacket.getSourceProtoAddress(),arpPacket.getDestinationProtoAddress()};
			}

	
		}
	catch(Exception e) {
			e.printStackTrace();	
		}
	}


	public void updateTable(final String[] info) {
	SwingUtilities.invokeLater(new Runnable() {
	public void run() {
	DefaultTableModel model = (DefaultTableModel)table.getModel();
	model.addRow(info);
	}
	});
	
	}
	}
	}

Open in new window


help me !!
SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of keviin55
keviin55

ASKER

i have installed the jpcap librery at /usr/lib/jpcap-0.01.16 then i added it to build path.
what about the properties file, where is that?
SHould be in your project I think
Yes the property file needs to be in the project root folder. Just place the properties file int the same place you have created your src
thank you for your answer but i can find the proporties file haw can i find it please ?!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial