0

A newbie here so apologies in advance for asking anything silly/obvious. I am trying to run a java application on a Gumstix overo board (linux kernel 2.6.34). So far, I have installed JamVm (jvm), jikes compiler and classpath libraries (as per instructions in this tutorial). I have run a HelloWorld program and it seemed fine.

Now when I try to run another application (say 'MyApp') that uses 'jpcap' libraries, the jvm gives me an error that looks like this: Exception during event dispatch: java.lang.UnsatisfiedLinkError: Native libarary 'jpcap' not found (as file 'libjpcap.so') in gnu.classpath.boot.library.path and java.library.path . . .

This application was compiled using Netbeans 7.1. It generated a dist folder whose structure is this:

dist: |-- MyApp.jar |-- Readme |-- lib (folder) |---|-- jpcap.jar |---|-- swing-layout-1.0.4.jar

The readme says that in order to deploy this application, one should go to the dist folder and type 'java -jar "MyApp.jar". When I do so ('jamvm -jar MyApp.jar'), I get the error mentioned above.

My gumstix board has got libpcap-1.1.1-r1.6 installed. (I found /usr/lib/libpcap.so.1 on my board.)

Does anyone know what's going wrong? Any advice would be highly appreciated.

Ps: I have posted this question on gumstix-users list just a few minutes ago . I am posting here as well just to have a better chance of a reply. Hope this is ok with everyone here.

  • 1
    Where on the target did you put the file `libjpcap.so` ? – Erik Ekman Mar 14 '12 at 19:12
  • @ErikEkman I don't have that file. I thought that the jar file in the dist folder should have everything I need. So, I guess I should find this file for my linux distro (angstrom) and simply copy it over into my board. I guess it would go in /usr/lib? – user1269789 Mar 14 '12 at 19:21
  • @ErikEkman thanks Erik. I haven't actually managed to find the libjpcap.so file. I do have a jpcap tar ball, but I am not sure if it's safe to copy it on Gumstix and then do a 'make install'. All the documentation on Gumstix suggests either (i) using opkg or (ii)cross-compiling using openEmbedded. However, that is a separate question and should be asked in a new thread. (I have accepted your answer. many thanks) – user1269789 Mar 15 '12 at 18:31

1 Answers1

0

The libjpcap.so should be in gnu.classpath.boot.library.path or java.library.path as the error states. You can print these paths by getting them with System.getProperty("java.library.path") but /usr/lib is a good guess.

Erik Ekman
  • 2,051
  • 12
  • 13
  • thanks a lot for answering. I don't seem to find this file for my linux distro. The rpms [here](http://rpmfind.net/linux/rpm2html/search.php?query=libjpcap.so) do not include anything for angstrom linux. The opkg utility on gumstix doesn't find jpcap either. (Sorry this is off-topic) – user1269789 Mar 14 '12 at 19:44
  • It is not that important that it is for your distro, as long as the architecture is the same. Run `ldd libjpcap.so` on target, and if all dependencies are found, you should be fine. – Erik Ekman Mar 14 '12 at 20:19
  • I have now got libjpcap.so on my Gumstix ( I compiled jpcap natively, using 'make'). For some reason, my java application still can't find it. I have tried putting this file at various locations (1.the folder containing the java app, 2. in /usr/lib/, 3. in the folder containing jamvm classes), but to no avail. I have a suspicion that I'm not setting some library paths correctly. I am setting BOOTCLASSPATH=/usr/share/jamvm/classes.zip:/usr/share/classpath/glibj.zip, but I am not setting any other variable. Can someone help me with this problem? – user1269789 Mar 21 '12 at 23:41
  • did you compile it on your pc? In that case you need to crosscompile for your target architecture. Run `file libjpcap.so` and make sure it does not say i386 or x86_64 but the mips/arm/whatever of your target. – Erik Ekman Mar 22 '12 at 10:32
  • (thank you Erik for staying with me.) No I compiled it directly on my Gumstix board, using the Makefile in jpcap/src/c/. I am wondering if I need to have jre6 or jdk6 on my board. I currently have Jamvm on my board, but not JRE. ( I thought they're the same, but I now know they are not!). When I type 'java -version', the gumstix returns: java version "1.5.0", JamVM version 1.5.3. ...(and some more stuff). – user1269789 Mar 22 '12 at 18:18
  • (continued) note that the jpcap website says that jdk or jre are needed. I ignored this because I thought Jamvm would be sufficient. Do you think that might be the cause of my problems? – user1269789 Mar 22 '12 at 18:33
  • A bit more info: the underlying 'libpcap' libraries are working fine. I was able to run a simple C-language packet sniffer and it captured packets fine. It's only when I try to use jpcap that I run into trouble. – user1269789 Mar 22 '12 at 18:52
  • In the end, it turned out that I had to set the environment variable LD_LIBRARY_PATH to the folder containing 'libjpcap.so'. Also, the 'jpcap.jar' should be in classpath or (as I did it) in the folder containing my java application. Once these steps were done, my application compiled and ran. – user1269789 Mar 27 '12 at 08:52