4

I've made a project in Java using Eclipse using the jnetpcap library which needs WinPCap to be installed to work properly. However, there's no winpcap library included in my project only jnetpcap. But when i extract the project into a generated jar with libraries, or with the libraries in a different folder, it somehow doesn't work. Why does everything work when i run the program from eclipse, but not as an extracted project?

Thanks in advance.

Anders Lassen
  • 615
  • 2
  • 8
  • 20
  • 3
    There could be many reasons. What error do you receive exactly? Is it a class not found error? A dll load failure? – Pace Jan 26 '17 at 18:11
  • The winpcap libraries is included in ur project lib folder ..if not include it an then try. – Ankit Jan 27 '17 at 10:53
  • How are you generating the jar? Using the Executable jar file or simple jar file? If you are using simple jar you have to choose your dependencies. – Nuria Jan 27 '17 at 11:36

3 Answers3

2

I faced the same issue few years back. Jnetpcap for eclipse comes with winpcap. You need to export your project on eclipse as runnable jar. There you have an option to select which says extract required libraries in the generated jar. In this way, the all the dependent libraries will be included in the exported runnable jar file.

The links below are some of the helpful links:

Create runnable jar in eclipse

Visit the post on winpcap website jnetpcap: a java wrapper for libpcap and winpcap

bpjoshi
  • 1,091
  • 16
  • 23
1

Does this thread helps you out? I would guess that you have not wrapped your dependency into the .jar file but only in eclipse. That is why it works inside your IDE.

Community
  • 1
  • 1
Nikolas
  • 2,066
  • 1
  • 19
  • 20
0

You didn't declare your main class for the jar file. Right click on your solution in eclipse->Run as-> Run configuration -> Main class -> choose you main class. Now build your jar from the beginning and try to execute it.

The scion
  • 1,001
  • 9
  • 19