Hi im trying to read com port, so I add library to my java directory like
they wrote here but when Im witing simple code like
import java.util.Enumeration;
import javax.comm.*;
public class CompotCore {
public static void main(String[] args)
{
Enumeration list = CommPortIdentifier.getPortIdentifiers();
}
}
I get such error:
java.lang.UnsatisfiedLinkError: no Serial in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at gnu.io.RXTXCommDriver.<clinit>(RXTXCommDriver.java)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at javax.comm.CommPortIdentifier.loadDriver(CommPortIdentifier.java:237)
at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:109)
at CompotCore.main(CompotCore.java:11)
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.sun.comm.SunrayInfo.isSessionActive()Z
at com.sun.comm.SunrayInfo.isSessionActive(Native Method)
at com.sun.comm.Portmapping.registerCommPorts(Portmapping.java:155)
at com.sun.comm.Portmapping.refreshPortDatabase(Portmapping.java:100)
at javax.comm.CommPortIdentifier.<clinit>(CommPortIdentifier.java:138)
at CompotCore.main(CompotCore.java:11)
i read that I had to add System.load("Serial"); with full path but I dont have such library and dont know where to find it.
On the site you link to it includes instructions to copy two native libraries into your JRE lib dir:
cp rxtx-bins.1/1.4/i386-pc-linux/libParallel.so /usr/java/j2sdk1.4.0/jre/lib/i386/
cp rxtx-bins.1/1.4/i386-pc-linux/libSerial.so /usr/java/j2sdk1.4.0/jre/lib/i386/
Are they there?
Be sure you are copying them into the correct JRE. What does which java tell you?
An alternative to copying to jre/lib would be to have them in some other location and then point to that dir with the System Property java.library.path, e.g. you would execute Java like this to start your program
java -Djava.library.path=<dir_with_those_libs> <your_other_args>
Update
OK I downloaded the rtxt tar and took a look. After you untar it, you have the following (one example):
ls -l rxtx-bins.1/1.4/i386-pc-linux/
total 44
-rwxr-xr-x 1 root root 9700 Dec 5 2001 libParallel-1.4.15.so
lrwxrwxrwx 1 root root 21 Jul 6 03:23 libParallel.so -> libParallel-1.4.15.so
-rwxr-xr-x 1 root root 31400 Dec 5 2001 libSerial-1.4.15.so
lrwxrwxrwx 1 root root 19 Jul 6 03:23 libSerial.so -> libSerial-1.4.15.so
If you followed the instructions from that page, you will have only copied the links, not the actual libs. So the solution will be to copy ALL the files, something like this:
cp rxtx-bins.1/1.4/i386-pc-linux/* /usr/java/j2sdk1.4.0/jre/lib/i386/
Or alternatively to execute Java something like:
java -Djava.library.path=~/rxtx-bins.1/1.4/i386-pc-linux:$LD_LIBRARY_PATH <your_other_args>
The page that you linked to offers you to download the RXTX package. In that archive file there are the native libraries that you need for different platforms.
You just have to make sure that Java can find the relevant native library for the OS that you are using. You can do that by specifying the directory that contains the native library in the java.library.path system property, which you can set on the command line like this:
java -Djava.library.path=C:\Folder\That\Contains\TheDLL CompotCore
For Linux, obviously:
java -Djava.library.path=/folder/that/contains/the_so CompotCore
(Ofcourse, substitute the actual directory in the command).
Related
I am trying to run a test file InspectVM from libguestfs library inorder to have accesss to a disk image in windows. However, I have the following errors on my console
run:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no guestfs_jni in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at madjava.com.redhat.et.libguestfs.GuestFS.<clinit>(GuestFS.java:51)
at madjava.examples.InspectVM.main(InspectVM.java:30)
C:\Users\CyberSOFONET\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)#
I searched allover the internet and find that I should set java.libraly.path pointing to location of the guestfs_jni. my major problem is that I do not have any file with that name guestfs_jni. Do I need to make one myself or can I find it somewhere. any kind of help is appriciated. am a newbie in JNI so I dont have much imformation on it
You're looking for a file called guestfs_jni.dll. Usually the native library comes with the jar file.
From http://libguestfs.org/guestfs-java.3.html:
Libguestfs for Java is a Java Native Interface (JNI) extension, supplied in three parts: libguestfs.jar, libguestfs-VERSION.jar, libguestfs_jni.so, libguestfs.so
So the distribution comes with libguest_jni.so which ist for Linux and not for Windows. IIRC, there is no libguestfs for Windows. So you would first have to find out if it is even possible to compile libguestfs using Cygwin and if yes build it yourself.
If you're on Windows 10 you could try installing libguestfs and a Java runtime for the Linux subsystem and run inside the subsystem.
I have a problem including a native library to my Java project on Linux Ubuntu.
A directory /mnt contains files treedb.jar and jkyotocabinet.so which are needed for launching:
root#vtt9:/mnt# ls -l
-rwxr-xr-x 1 root root 1948919 Mar 11 2014 jkyotocabinet.so
-rwxr-xr-x 1 root root 1404322 Nov 18 16:11 treedb.jar
I start the program with param -Djava.library.path=.:
root#vtt9:/mnt# sudo java -Xms5000m -Xmx51000m -d64 -jar
-Djava.library.path=. treedb.jar
The program prints strings to the console:
current dir = /mnt/.
java library path = .
Then I have an exception on System.loadLibrary("jkyotocabinet");:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jkyotocabinet in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at treedb.Main.main(Main.java:27)
Also I looked in java -XshowSettings:properties, put jkyotocabinet.so to another directories in java.library.path, set programmatically System.setProperty( "java.library.path", "." );
I don't understand what is wrong with it? On Windows it works great. I need only replace .so to .dll.
I was getting a NoSuchFileException when I was trying to access a file so I went through the usual process, checked the file existed, etc. I did this by checking the exception:
java.nio.file.NoSuchFileException: /var/config/file/test111.txt
then
vim /var/config/file/test111.txt
to verify the file actually existed. After some further testing I realized java couldn't see the /config folder.
File f = new File("/var");
f.list();
This returned some of the files and folders in /var, but not others, including /var/config. I did a ls -lah on the folder to check permissions and as far as I can tell there is no difference between what java can and can't see. For example it can see /var/cache
drwxr-xr-x 6 root root 4096 Feb 24 09:03 cache
drwxr-xr-x 3 root root 4096 Feb 24 09:04 config
Why would java be able to see some folders but not others when permissions are the same between folders?
Thanks!
I'm trying to run an example file that comes with ruby-processing, but it crashes with this error each time:
me$ rp5 run ~/rp_samples/samples/processing_app/library/movie/loop.rb
/Users/jimmy/rp_samples/samples/processing_app/library/movie/loop.rb:14 warning: ambiguous Java methods found, using background(int)
Java::JavaLang::UnsatisfiedLinkError
Could not load library: gstreamer
org.gstreamer.lowlevel.GstNative.load(org/gstreamer/lowlevel/GstNative.java:53)
org.gstreamer.lowlevel.GstNative.load(org/gstreamer/lowlevel/GstNative.java:43)
org.gstreamer.Gst.<clinit>(org/gstreamer/Gst.java:101)
java.lang.reflect.Constructor.newInstance(java/lang/reflect/Constructor.java:513)
RUBY.setup(/rp_samples/samples/processing_app/library/movie/loop.rb:16)
processing.core.PApplet.handleDraw(processing/core/PApplet.java:2361)
processing.core.PGraphicsJava2D.requestDraw(processing/core/PGraphicsJava2D.java:240)
processing.core.PApplet.run(processing/core/PApplet.java:2256)
java.lang.Thread.run(java/lang/Thread.java:695)
Here's what I've tried:
I was using the bundled (with ruby-processing) jruby-complete, but when this didn't work, I installed the regular jruby package.
I've already added the line from the answer on this page to resolve a Java::JavaLang::RuntimeException to get this far.
I found this question for java, but installing gstreamer via homebrew (on a Mac) didn't work and installing the universal pkg from gstreamer hasn't gotten me any further either.
I just want to play with ruby-processing :(. Let me know if I haven't given enough detail, but does anyone have any ideas? Thanks!
--
EDIT
I believe by looking at the gstreamer-java Google group, that the new version of gstreamer (> 1.0) isn't compatible. I found a collection of the old 0.10 gstreamer libs on homebrew and installed them.
I tried a 'sudo find / -iname "gstnative.java", and I can't seem to find the GSTNative.java file that this error is coming from. Maybe it's packaged somehow with ruby-processing? Anyway.. I found this line in gstreamer-java/src/org/gstreamer/lowlevel/Main.java:
System.setProperty("jna.library.path", "/usr/share/java:/opt/local/lib:/usr/local/lib:/usr/lib");
If I check for the files mentioned in the below comment (la /usr/local/lib/ | grep "gst"), I see them all and they're named both ways (0.10.0.dylib or 0.10.dylib). E.g.
lrwxr-xr-x 1 jimms admin 71 Jan 12 15:24 libgstinterfaces-0.10.0.dylib -> ../Cellar/gst-plugins-base010/0.10.36/lib/libgstinterfaces-0.10.0.dylib
lrwxr-xr-x 1 jimms admin 65 Jan 12 15:24 libgstinterfaces-0.10.a -> ../Cellar/gst-plugins-base010/0.10.36/lib/libgstinterfaces-0.10.a
lrwxr-xr-x 1 jimms admin 69 Jan 12 15:24 libgstinterfaces-0.10.dylib -> ../Cellar/gst-plugins-base010/0.10.36/lib/libgstinterfaces-0.10.dylib
So they seem to be there, but maybe I'm not understanding exactly what it's looking for. Any help is appreciated!
It's working now:
I'm not 100% sure about what fixed the problem finally, but, for future-googlers, here's a list of elements that seem to be required:
Do a brew search gst and install anything with 010 appended to it. Gstreamer-java has not been updated to be compatible with any version past gstreamer-0.10.
I updated my JDK to version 7 update 72 (maybe 8 will work, but I haven't tried). At this point, I removed the "java_args": "-d32" line from my .rp5rc file because 32bit mode wasn't supported.
The ruby-processing script doesn't seem to understand relative paths looks in a directory that's relative to where you run the rp5 command (instead of relative to the sketch itself) when loading a file with Movie.new, and so I changed it to an absolute path and Eureka!
--
Edit
Edited step 3 above for clarity: If I had cded into ~/rp_samples/samples/processing_app/library/movie/ before running rp5 run loop.rb it would have helped the troubleshooting process.
I'm trying to use the SWI-Prolog JPL library, but I'm having problems.
I'm trying to let my Eclipse project access JPL, but when I try to start the program, I get the following error:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no jpl in java.library.path
I copied the jpl.jar into my project directory, and I set it on the build path. Additionally, I pass the following VM arguments:
-Djava.library.path="C:\Program Files\Prolog\bin"
(That's the directory where Prolog was installed).
What am I doing wrong?
EDIT: I don't seem to have the libpl.dll anywhere on my computer. Could this be causing my problem?
The jvm.dll of your running JDK/JRE must be available in your system PATH so that jpl.dll from java.library.path loads properly.
You have to take care to 32 bits / 64 bits consistency between your JPL installation and your running JVM - so do not try any mix.
Here is information from an old installation doc.
For such installation support, you should use the JPL mailing list.
You should set the java.library.path to the folder where the jpl.dll file is located. As far as I know it is the Prolog\bin folder.
A system-wide solution in a Mac environment (SWI-Prolog version 7.1.4 for x86_64-darwin13.1.0) would be to create the following symlink:
ln -s /usr/local/Cellar/swi-prolog/7.1.4/libexec/lib/swipl-7.1.4/lib/x86_64-darwin13.1.0/libjpl.jnilib /Library/Java/Extensions/libjpl.jnilib
Could be rather
ln -s
/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin/libjpl.dylib
/Library/Java/Extensions/libjpl.dylib
? (no .inilib was found under darwin folder)
In my case still error on mojave (SWI-Prolog (threaded, 64 bits, version 8.0.2)):
Jan 03, 2020 12:10:55 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [ACTIONS] in context with path [/SVIZ] threw exception [Servlet execution threw an exception] with root cause
java.lang.UnsatisfiedLinkError: /Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin/libjpl.dylib: dlopen(/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin/libjpl.dylib, 1): Library not loaded: #rpath/libswipl.8.dylib
Referenced from: /Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin/libjpl.dylib
Reason: image not found