java.lang.UnsatisfiedLinkError while calling a dll from java - java

I have a java programm which needs a .jar and a .dll file. If running the java programm from command line it works. Running it out of eclipse I get the following error:
java.lang.UnsatisfiedLinkError: com.osisoft.rdsa.RDSAChannel.GetDASVersion(J)S
at com.osisoft.rdsa.RDSAChannel.GetDASVersion(Native Method)
at com.osisoft.rdsa.RDSAChannel.<init>(RDSAChannel.java:58)
at com.osisoft.rdsa.NativeRDSA.create(NativeRDSA.java:185)
at com.osisoft.rdsa.NativeRDSA.create(NativeRDSA.java:127)
at com.osisoft.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:75)
at com.osisoft.jdbc.DriverExtension.connect(DriverExtension.java:121)
at com.osisoft.jdbc.Driver.connect(Driver.java:261)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at testclients.jtesterbase.JTesterBase.connect(JTesterBase.java:417)
at testclients.jtesterbase.JTesterBase.init(JTesterBase.java:182)
at testclients.jtesterbase.JTesterBase.main(JTesterBase.java:552)
what is the problem?
The .dll file is in C:\Windows\system\32\RDSAWrapper64.dll, so it has already be in the java.lang search path.
What environment changes between executing on console and executing in eclipse?
Has somebody some tips. I tried to fix it for hours.
Thanks so much for your help.

Related

No suitable driver found for jdbc:sqlserver - works in Eclipse, not in JAR

I have a Java script that functions correctly in Eclipse, but when I export it as an executable JAR and try to run it from the Command Prompt I get the following error:
java.sql.SQLException: No suitable driver found for
jdbc:sqlserver://[servername]:1433;databaseName=[databasename];user=[username]_sync;password=[password];
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at SFChecker_pack.SFChecker3.sql(SFChecker3.java:405)
at SFChecker_pack.SFChecker3.main(SFChecker3.java:137)
In Eclipse my Build Path incorporates mssql-jdbc-7.2.2.jre11.jar
What do I need to do to get this working from Command Prompt?

NoClassDefFoundError using bluetooth in java

I asked a question earlier here: NoClassDefFoundError with bluecove's javax.microedition
but got no responses.
I am trying to run some java code (Server.java) that requires bluetooth, so I installed the bluecove-2.1.0.jar file in C:\Program Files\Java.
I compile my code with javac -cp "C:\Program Files\Java\bluecove-2.1.0.jar";. Server.java and run it with java Server -cp "C:\Program Files\Java\bluecove-2.1.0.jar"
It compiles successfully, but when I run it, I get the error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: javax/microedition/io/Connection
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.microedition.io.Connection
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
Any ideas where i've gone wrong?
EDIT: Following Minus' answer, to fix the error that followed, I also needed to use a different .jar file which I downloaded from http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/2.1.1-SNAPSHOT.63/
The problem is that the .dll is not loaded correctly.
The library should contain a .dll that will be saved on disk and loaded, maybe the program cannot save the .dll to disk or cannot read it.
Extract the .dll and follow bluecove installation instructions on Native Library location.
For example:
Create a directory c:\blue, and a directory blue\lib.
Put the files like this:
C:\blue\Sever.java
C:\blue\Sever.class
C:\blue\[bluecove_native_library].dll
C:\blue\lib\bluecove-2.1.0.jar
Open a cmd (Command Prompt) on c:\blue
Try to run the app like this:
java -cp .;lib\bluecove-2.1.0.jar -Dbluecove.native.resource=false Server
This way you will have both Server.class and bluecove-2.1.0.jar in classpath and the DLL in path (since on Windows the current dir is in path).
Add a current folder to a classpath (.;) and make sure that your code is in a package-name folder.
So if your server has a package name :
mypackage
make sure that your class code is in a /mypackage directory
than go to a parent folder to /mypackage and call:
java -cp ".;C:\Program Files\Java\bluecove-2.1.0.jar" mypackage.Server

How do I use mysqlimport?

Here is the command I am running using Runtime.getRuntime().exec() in Java:
mysqlimport --fields-terminated-by=, --lines-terminated-by="|" --local
--user=u --password=p DatabaseName
txtpath
Here is the error I get:
java.io.IOException: Cannot run program "mysqlimport": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at databaseCommunication.UploadThread.run(UploadThread.java:66)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 5 more
It seems like the problem should be that mysqlimport.exe is not installed or is not installed in the correct place, but I have tried downloading the mySQL utilities from http://dev.mysql.com/downloads/windows/installer/5.6.html and from https://dev.mysql.com/downloads/utilities/.
In order to make sure the problem was not that it could not find the file at "txtpath," I typed the full path into the command prompt, and the correct file was opened, so the error is definitely referring to mysqlimport.exe.
Googling my problem, the only threads I've been able to find refer to something called "Sqoop" which I am not familiar with, and they usually recommend downloading the mysql utilities.
For more context, I have been using BCP to upload data from a txt file to a sql server database, but now I need to do the same thing with mysql. If there is any way to use BCP (I'm pretty sure there isn't) or something else to bulk upload data from a local file I would be open to hearing that as well.
EDIT:
I am using Windows 8 on a remote desktop. I have manually added mysqlimport.exe to the PATH environment variable and it still gives the same error.
If you are on Windows, then try putting mysqlimport.exe as the command rather than just mysqlimport. If that still does not solve your problem, make sure that 'mysqlimport.exe' is in your PATH environment variable.

Using tess4j, ghostscript and Java with Eclipse on mac

I am trying to get tess4j working in a simple test application to perform OCR on a pdf file but receive the following error and cannot fathom out how to resolve it:
Exception in thread "main" java.lang.RuntimeException: Unable to load library 'gs': dlopen(libgs.dylib, 9): image not found
Please download, install GPL Ghostscript from http://sourceforge.net/projects/ghostscript/files and/or set the appropriate environment variable.
at net.sourceforge.vietocr.PdfUtilities.convertPdf2Tiff(Unknown Source)
at net.sourceforge.vietocr.ImageIOHelper.getIIOImageList(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at net.sourceforge.tess4j.Tesseract.doOCR(Unknown Source)
at Test.main(Test.java:11)
I have got eclipse to print out my path file as it sees it and it contains /usr/loca/bin/gs (checked as correct with which gs) as needed and I can happily run gs from the terminal. Any ideas on how to get this working?
The code is shown in the image at https://dl.dropboxusercontent.com/u/61920208/Screen%20Shot%202013-09-02%20at%2013.44.24.png
Thanks in advance for any help
As per the suggestion, reinstalling ghostsrcipt (via ports rather than the dmg)sorted this out for me.

7Zip-JBinding UnsatisfiedLinkError

I've looked through a number of the UnsatisfiedLinkError threads on here and nothing seems to quite fit my problem.
I am trying to get this api working: 7ZipBind
However I am having an issue, and cant get the thing to work. I am running some of its example code from the commandline like so:
C:>java -classpath
"/sevenzipTest.jar;/sevenzipjbinding-AllWindows.jar;\sevenzipjbinding.jar"
com.poc.sevenzip.SevenZipSimple c:\archive\test.zip
However when I try to run it I get the error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\Users\XXXX\AppData\Local\Temp\SevenZipJBinding-9640553\lib7-Zip-JBinding.dll: Can't
find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at net.sf.sevenzipjbinding.SevenZip.initSevenZipFromPlatformJARIntern(SevenZip.java:428)
at net.sf.sevenzipjbinding.SevenZip.initSevenZipFromPlatformJAR(SevenZip.java:235)
at net.sf.sevenzipjbinding.SevenZip.ensureLibraryIsInitialized(SevenZip.java:578)
at net.sf.sevenzipjbinding.SevenZip.openInArchive(SevenZip.java:567)
at com.poc.sevenzip.SevenZipSimple.runZip(SevenZipSimple.java:25)
at com.poc.sevenzip.SevenZipSimple.main(SevenZipSimple.java:64
What I am confused about, is why it says it cant locate the libraries (dll files), when the libraries are stored within the <file_path>/sevenzipjbinding-AllWindows.jar file... I am obviously not doing something correct here, and was hoping some1 can give me some pointers.
Cheers
The bug fix was released. Please, use version 1.06rc or above.
Download URL:
All versions
4.65-1.06rc-extr-only
The following instructions are for Windows x86 and 7 Zip JBinding version 4.65-1.05 RC. Download the following DLLs.
libstdc++-6.dll
libgcc_s_dw2-1.dll
gpsvc.dll
sysntfy.dll
Add the DLLs into the Windows-x86 directory in sevenzipjbinding-AllPlatforms.jar. Then append the following lines to sevenzipjbinding-lib.properties in the Windows-x86 directory in the jar.
sevenzipjbinding.libname.3=gpsvc.dll
sevenzipjbinding.libname.4=libgcc_s_dw2-1.dll
sevenzipjbinding.libname.5=libstdc++-6.dll
sevenzipjbinding.libname.6=sysntfy.dll
Instead of modifying the jar file, one could put the DLLs in the PATH (not classpath).
In order to figure this out, I extracted lib7-Zip-JBinding.dll from sevenzipjbinding-AllPlatforms.jar. I then opened the file in Dependency Walker.

Categories