how can I use jpcap library in my project? - java

I am using Netbeans 7, and I have 32 bit JDK version 1.7.0.40. I want to use jpcap library to analyze incoming packets.
I do following to be able to use jpcap.
I added "jpcap.jar" into my project's library.
I copied "jpcap.dll" into my JRE/bin
I copied "jpcap.jar" into my JDK/jre/lib/ext
I copied "jpcap.jar" into my JRE/lib/ext
However, I get the exception below:
Exception in thread "main" java.lang.UnsatisfiedLinkError: jpcap.JpcapCaptor.getDeviceList()[Ljpcap/NetworkInterface;
at jpcap.JpcapCaptor.getDeviceList(Native Method)
at src.JpcapAnalyzer.<init>(JpcapAnalyzer.java:19)
at src.Main.main(Main.java:31)
Java Result: 1
I appreciate for any recommendations.
Edit :
After 2 weeks posting this question, I received no answers. Then I want to share my experience with the community.
I tried another library,jnetpcap, which can be downloaded at https://sourceforge.net/projects/jnetpcap/. I easily implemented it. You can use this library both in 32 bit and 64 bit OS and JDK.

Related

UnsatisfiedLinkError for tomcat7 windowsOS

I am getting below error on my web app.
java.lang.UnsatisfiedLinkError: Can't obtain updateLastError method for class com.sun.jna.Native
com.sun.jna.Native.initIDs(Native Method)
com.sun.jna.Native.<clinit>(Native.java:139)
com.sun.jna.Pointer.<clinit>(Pointer.java:41)
com.sun.jna.platform.win32.WinNT$HANDLEByReference.<init>(WinNT.java:1114)
com.sun.jna.platform.win32.WinNT$HANDLEByReference.<init>(WinNT.java:1110)
waffle.windows.auth.impl.WindowsAuthProviderImpl.logonDomainUserEx(WindowsAuthProviderImpl.java:193)
waffle.windows.auth.impl.WindowsAuthProviderImpl.logonDomainUser(WindowsAuthProviderImpl.java:181)
waffle.windows.auth.impl.WindowsAuthProviderImpl.logonUser(WindowsAuthProviderImpl.java:212)
waffle.apache.MixedAuthenticator.post(MixedAuthenticator.java:233)
waffle.apache.MixedAuthenticator.authenticate(MixedAuthenticator.java:112)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:577)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
I searched that it may be due to some old version access of jna but removing jna is giving me NoClassDefErrors for com.sun.jna.Pointer. Also tried -Djna.nosys=true but its also not solving the issue.
I also tried -Djava.library.path=
from What is the cause of an UnsatisfiedLinkError? but it is also not working..
Any suggestion is highly appreciated.
I resolved this by deleting an old jnidispatch.dll file from my machine.
I'm using Gradle and Tomcat on Windows 7.
Delete the jnidispatch.dll file in C:\Users\<username>\.gradle\native\jna\win32-amd64
Don't have enough rep to just comment, but this is vaguely similar to a question i asked a couple years ago called UnsatisfiedLinkError, despite setting Djava.library.path variable
Somebody suggested making sure i was using the right architecture type, i.e. using 64 bit jdk with 64 bit Tomcat & 32 with 32. Does that match up?

Sqlite java.lang.UnsatisfiedLinkError in linux

I have a program that uses Sqlite database. It works fine on Windows (exported jar or directly in Eclipse) but when I move it to linux server (plan is to use run it at certain intervals, cron job). I'm exporting it to jar from Eclipse and packing the sqlite-jdbc4-3.8.2-SNAPSHOT.jar with it. Error is this:
/$ /usr/bin/java -jar /home/username/Software.jar /home/username/
java.lang.UnsatisfiedLinkError: /tmp/sqlite-3.8.2-amd64-libsqlitejdbc.so: /tmp/sqlite-3.8.2-amd64-libsqlitejdbc.so: failed to map segment from shared object: Operation not permitted
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open(Ljava/lang/String;I)V
at org.sqlite.core.NativeDB._open(Native Method)
at org.sqlite.core.DB.open(DB.java:161)
at org.sqlite.core.CoreConnection.open(CoreConnection.java:145)
at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:66)
at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:21)
at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:23)
at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:44)
at org.sqlite.JDBC.createConnection(JDBC.java:113)
at org.sqlite.JDBC.connect(JDBC.java:87)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
....
So before you ask, I've made sure that sqlite-3.8.2-amd64-libsqlitejdbc.so in /tmp/ has all permissions (rwxrwxrwx). Still that native library is causing problems. It does get copied in /tmp/ folder though. That being said I totally suck in Linux... and for that reason I'm pretty much clueless what to try next.
What should I do? Switch connector?
EDIT:
Solved the problem by using System.setProperty("java.io.tmpdir", "/home/username/"); Apparently it for some reason couldn't execute the native library from tmp folder... Probably because it was created by root. Also I had to revert back to sqlite-jdbc-3.7.2.jar because the new one crashes on linux.
I had same problem, and I found the solution in this GitHub issue:
JAVA_OPTS=-Djava.io.tmpdir=/path/to/some/other/tmpdir bin/cerebro
Also look at this other SO answer.

What is libmuxer library ? If I run my server or application then I find these

If I run my program or server then I find alsways this error message. Can anyone tell me and help me please.. I will be very thankfull to you.
<Jul 29, 2013 3:01:55 AM ACT> <Error> <Socket> <BEA-000433> <Unable to load performance pack. Using Java I/O instead.
Please ensure that libmuxer library is in :'C:\j2sdk1.4.2_17\bin;C:\bea\weblogic81\bin;C:\bea\weblogic81\server\bin'
java.lang.UnsatisfiedLinkError: no muxer in java.library.path
java.lang.UnsatisfiedLinkError: no muxer in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1517)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at weblogic.socket.PosixSocketMuxer.<init>(PosixSocketMuxer.java:30)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at weblogic.socket.SocketMuxer.makeTheMuxer(SocketMuxer.java:82)
at weblogic.socket.SocketMuxer.getMuxer(SocketMuxer.java:49)
at weblogic.t3.srvr.ListenThread.initServerSocket(ListenThread.java:690)
at weblogic.t3.srvr.ListenThread.run(ListenThread.java:205)
"...this indicates that the Native Libraries are not properly being picked up the Weblogic server. This happens when the weblogic installed as 32 Bit on a 64 Bit Operating System or vice versa. In such scenario we need to explicitly specify the path to the Native Library."
Add the following to the setDomainEnv.sh
-Djava.library.path=/opt/bea/wlserver_10.3/server/native/solaris/sparc64/
Enable "Native IO" check box under each servers Tuning Tab.
Restart the servers.
http://weblogic.middlewarebase.com/2013/04/unable-to-load-performance-pack-using.html
I have the some problem, and thanks to sᴜʀᴇsʜ-ᴀᴛᴛᴀ for the hint! It looks like a 32bit/64bit issue. By the way, I'm using WebLogic 12 on a 64bit Centos5.
Note that the libmuxer.so is provided with weblogic for many archs, in fact
$ find $MW_HOME -name *muxer*
/application/weblogic/wlserver/server/native/macosx/libmuxer.jnilib
/application/weblogic/wlserver/server/native/linux/s390/libmuxer.so
/application/weblogic/wlserver/server/native/linux/ia64/libmuxer.so
/application/weblogic/wlserver/server/native/linux/x86_64/libmuxer.so
/application/weblogic/wlserver/server/native/linux/i686/libmuxer.so
/application/weblogic/wlserver/server/native/linux/s390x/libmuxer.so
I edited the file $MW_HOME/wlserver/common/bin/commEnv.sh, where I found
#JAVA_USE_64BIT, true if JVM uses 64 bit operations
JAVA_USE_64BIT=false
and updated with
#JAVA_USE_64BIT, true if JVM uses 64 bit operations
JAVA_USE_64BIT=true
This worked for me, the Error you reported is gone.
Good luck!

HypergraphDB Netbeans settings

I want to do something with the HypergraphDB in Java. I'm not very familiar with this language and IDE Netbeans.
I followed steps describing the HGDB installation:Link to tutorial
Now I want to write an example in Java (using NetbeansIDE).
So I created new project, added refferences to the downloaded libraries. OK, now I'm able to import packages with HGDB. The only thing I have in my main method is HyperGraph HG = new HyperGraph(dbLocation);. This code compiles. But get following runtime error:
run:
checkpoint kbytes:0
checkpoint minutes:0
java.lang.IllegalStateException: There is 1 existing transaction opened against the Environment.
Aborting open transactions ...
aborting <Transaction id="28">
at com.sleepycat.je.Environment.close(Environment.java:383)
at org.hypergraphdb.storage.bje.BJEStorageImplementation.shutdown(BJEStorageImplementation.java:178)
at org.hypergraphdb.HGStore.close(HGStore.java:355)
at org.hypergraphdb.HyperGraph.open(HyperGraph.java:392)
at org.hypergraphdb.HyperGraph.open(HyperGraph.java:213)
at org.hypergraphdb.HyperGraph.<init>(HyperGraph.java:200)
at hgdbtest.HgdbTest.main(HgdbTest.java:16)
Exception in thread "main" org.hypergraphdb.HGException: java.lang.NoSuchMethodError: org.hypergraphdb.storage.bje.LinkBinding.objectToEntry(Ljava/lang/Object;Lcom/sleepycat/je/DatabaseEntry;)V
at org.hypergraphdb.HyperGraph.open(HyperGraph.java:395)
at org.hypergraphdb.HyperGraph.open(HyperGraph.java:213)
at org.hypergraphdb.HyperGraph.<init>(HyperGraph.java:200)
at hgdbtest.HgdbTest.main(HgdbTest.java:16)
Caused by: java.lang.NoSuchMethodError: org.hypergraphdb.storage.bje.LinkBinding.objectToEntry(Ljava/lang/Object;Lcom/sleepycat/je/DatabaseEntry;)V
at org.hypergraphdb.storage.bje.BJEStorageImplementation.store(BJEStorageImplementation.java:234)
at org.hypergraphdb.HGStore.store(HGStore.java:119)
at org.hypergraphdb.HGTypeSystem.addPrimitiveTypeToStore(HGTypeSystem.java:185)
at org.hypergraphdb.HGTypeSystem.bootstrap(HGTypeSystem.java:234)
at org.hypergraphdb.HyperGraph.open(HyperGraph.java:355)
... 3 more
Java Result: 1
BUILD SUCCESSFUL (total time: 4 seconds)
I guess it's caused by the native API of the BerkeleyDB.
According to the tutorial, in project options I supply the -Djava.library.path=$HGDB_ROOT/lib/native/$PLATFORM argument on Run card as a VM Option. Instead of the system variables I use full-path to the libraries.
My OS in Windows7. I'm not sure about using slashes or backslashes or double-backslashes as a path-separator.?
So a simply question is: how have I to set up the IDE for using the HypergraphDB?
Thank you for advices!
Judging from the stack trace, you are using the latest version of HyperGraphDB. In that version, the native API is not used. Rather, it's Java only libraries. You have to include the BerkeleyDB Java Edition 5.0.34 jar in your runtime classpath. You can get it either from the Oracle http://www.oracle.com/technetwork/products/berkeleydb/downloads/index.html or from the HyperGraphDB Maven repository: http://hypergraphdb.org/maven/org/hypergraphdb/hgbdbje/1.2/hgbdbje-1.2.jar
I had the same issue. I fixed it (by accident) by fixing the order of the libraries on which you're HyperGraphDB application relies on. The library je-[version].jar has to be ABOVE (and hence to be referenced before) db-[version].jar

Jacob (Java / COM / ActiveX) Throws ComFailException

I am using Jacob a Java-COM bridge and I have placed the required dll to -C:\WINDOWS\system32\jacob-1.14.3-x86.dll. I have also added the required jar file to -
C:\Program Files\Java\jdk1.6.0_18\jre\lib\ext\jacob-1.14.3.jar.
Until yesterday I was able to use it, today I uninstalled some unrequired .Net softwares on my machine and suddenly it stopped working and throws following error -
com.jacob.com.ComFailException: Can't co-create object
at com.jacob.com.Dispatch.createInstanceNative(Native Method)
at com.jacob.com.Dispatch.<init>(Dispatch.java:101)
at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58)
My machine belongs to "x86 Family 15 Model 4 Stepping 3". I have tried to de-register/register the dll using regsvr32.exe but to no luck. I have no idea how to bring it to work again..other wise I will have to format my machine..geeks pls hlp me out !
I wonder if anyone faced similar problem by any chance..
Anyways I had no other option than to restore my machine to last working date.
I guess some JAVA-COM class entries would have been accidently deleted from the registry.
Had no idea which was it exactly..
Finally "System Restore" was my solution :)

Categories

Resources