UnsatisfiedLinkError if app runs from Japanese folder - java

I get UnsatisfiedLinkError when trying to reach dll. This happens if bin folder is located in folder with Japanese name, system language and locale are set to Japan. I need to fix this.
In English environment and app located in Japanese named folder app does not run at all (fix unnecessary). In English environment and app located in English named folder app works fine.
Seems like NativeLibrary.load can not handle Japanese characters in library path.
Is this a bug in Java: https://bugs.openjdk.org/browse/JDK-8195129?
Error in console:
Exception in thread "main-FPSAWTAnimator-Timer0" java.lang.UnsatisfiedLinkError:
F:\Test\テスト\myApp\bin\jre\bin\jpeg.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1845)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.sun.imageio.plugins.jpeg.JPEGImageWriter$1.run(JPEGImageWriter.java:180)
at com.sun.imageio.plugins.jpeg.JPEGImageWriter$1.run(JPEGImageWriter.java:178)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.imageio.plugins.jpeg.JPEGImageWriter.<clinit>(JPEGImageWriter.java:177)
at com.sun.imageio.plugins.jpeg.JPEGImageWriterSpi.createWriterInstance(JPEGImageWriterSpi.java:96)
at javax.imageio.spi.ImageWriterSpi.createWriterInstance(ImageWriterSpi.java:351)
at javax.imageio.ImageIO$ImageWriterIterator.next(ImageIO.java:843)
at javax.imageio.ImageIO$ImageWriterIterator.next(ImageIO.java:827)
at sun.awt.datatransfer.DataTransferer.imageToStandardBytesImpl(DataTransferer.java:2203)
at sun.awt.datatransfer.DataTransferer.imageToStandardBytes(DataTransferer.java:2145)
at sun.awt.windows.WDataTransferer.imageToPlatformBytes(WDataTransferer.java:352)
at sun.awt.datatransfer.DataTransferer.translateTransferable(DataTransferer.java:1223)
at sun.awt.windows.WDataTransferer.translateTransferable(WDataTransferer.java:219)
at sun.awt.windows.WClipboard.setContentsNative(WClipboard.java:83)
at sun.awt.datatransfer.SunClipboard.setContents(SunClipboard.java:106)
at myPath.utils.c.<init>(Unknown Source)
at myPath.opengl.base.BaseViewer.renderSnapshot(Unknown Source)
at myPath.opengl.base.BaseViewer.access$1100(Unknown Source)
at myPath.opengl.base.e.a(Unknown Source)
at myPath.opengl.base.BaseViewer.render(Unknown Source)
at myPath.opengl.base.BaseViewer.display(Unknown Source)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:665)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:649)
at com.jogamp.opengl.swt.GLCanvas$2.run(GLCanvas.java:153)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1119)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:994)
at com.jogamp.opengl.swt.GLCanvas$3.run(GLCanvas.java:165)
at com.jogamp.opengl.swt.GLCanvas.runInGLThread(GLCanvas.java:970)
at com.jogamp.opengl.swt.GLCanvas.display(GLCanvas.java:682)
at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:75)
at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:416)
at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:172)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Paths:
F:\Test\テスト\myApp\bin\jre\bin\jpeg.dll
F:\Test\テスト\myApp\bin\appStarter.exe
Thanks for any hint!

Seems like the answer is here. sybase.allow.native.lib should be allowed:
System.setProperty("sybase.allow.native.lib", "true");
I need to run proper tests, but for now it seems to work.

Related

Trouble creating a runnable JAR from Eclipse

I'm trying to create a runnable JAR from https://bitbucket.org/madsen953/ethervisu in Eclipse. When I try to run it I get:
Exception in thread "Monitor" java.lang.UnsatisfiedLinkError: no jnetpcap 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 org.jnetpcap.Pcap.<clinit>(Unknown Source)
at ethervisu.monitors.JNetPcapMonitor.run(JNetPcapMonitor.java:28)
at java.lang.Thread.run(Thread.java:745)
java.lang.NullPointerException
at java.io.DataInputStream.readInt(DataInputStream.java:387)
at processing.core.PFont.<init>(Unknown Source)
at processing.core.PApplet.loadFont(Unknown Source)
at jgv.graphics.JGVGraphics$GraphVisuApplet.setup(JGVGraphics.java:80)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Exception in thread "Animation Thread" java.lang.RuntimeException: Could not load font /data/ArialMT-48.vlw. Make sure that the font has been copied to the data folder of your sketch.
at processing.core.PApplet.die(Unknown Source)
at processing.core.PApplet.die(Unknown Source)
at processing.core.PApplet.loadFont(Unknown Source)
at jgv.graphics.JGVGraphics$GraphVisuApplet.setup(JGVGraphics.java:80)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
I think this is because I'm unable to preserve the directory structure when creating the JAR. The font files are at the root instead of the data directory. How can I fix this?
try to check the path of JDK set properly pointing to correct library of java in buildpath.
and make sure correct jdk version is installed. no mess up with x86/x64 installs.`
The solution was to put the font files in a directory named data in the same directory as the jar and run it with java -Djava.library.path=jnetpcap-1.3.0 -jar thejar.jar where jnetpcap-1.3.0 is a directory where jnetpcap with its associated .so resides.

LWJGL with Eclipse i cannot fix the issue

Hello so I'm new with libraries and i followed a Youtube tutorial
https://www.youtube.com/watch?v=HRaJXVuZjRM
and he imports the libraries there and it works, i did too as he did and it works (when in eclipse), however the problem comes later, when i export the app (i always click package but have tried extract and doesn't work either), i cannot open the .jar file.
I have seen already countless threads with this problem, i searched on google and found this:
http://wiki.lwjgl.org/index.php?title=Setting_Up_LWJGL_with_Eclipse
which is basically what he did in the video, i open my manifest file inside of the jar file with 7zip and i get this:
``
Manifest-Version: 1.0
Rsrc-Class-Path: ./ jinput.jar jogg-0.0.7.jar jorbis-0.0.15.jar lwjgl.
jar slick.jar
Class-Path: .
Rsrc-Main-Class: com.tutorial.main.Game
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"
And if i run the application with the console i get this error:
Sun Dec 06 16:42:40 COT 2015 INFO:Initialising sounds..
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in
java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:95)
at org.lwjgl.Sys.<clinit>(Sys.java:112)
at org.lwjgl.openal.AL.<clinit>(AL.java:59)
at org.newdawn.slick.openal.SoundStore$1.run(SoundStore.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at org.newdawn.slick.openal.SoundStore.init(SoundStore.java:292)
at org.newdawn.slick.Sound.<init>(Sound.java:54)
at com.tutorial.main.AudioPlayer.load(AudioPlayer.java:17)
at com.tutorial.main.Game.<init>(Game.java:41)
at com.tutorial.main.Game.main(Game.java:159)
... 5 more
``
I suppose it means that it cannot find the libraries and stuff but i have already tried creating a lib folder and a natives folder inside, placing the stuff there and changing the manifest into this:
"
Manifest-Version: 1.0
Class-Path: lib/jinput.jar lib/jogg-0.0.7.jar lib/jorbis-0.0.15.jar
lib/lwjgl.jar lib/slick.jar
Main-Class: com.tutorial.main.Game
"
But it doesn't run it either, i really don't know what I'm doing wrong...
I found a temporal fix for anyone with this problem, remove the natives from eclipse (the native link) and then export and use JarSplice to generate the .jar, if you are using music and cannot open it just open the .jar create the folder you used for your files in your workplace (mine was res) and then drag the music files in there instead of outside... this is temporal since I'm sure there's better ways to do it.

UnsatisifiedLinkError - Any idea on how to fix this?

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: com.melloware.jintellitype.JIntellitypeException: Could not load JIntellitype.dll from local file system or from inside JAR
at com.melloware.jintellitype.JIntellitype.<init>(JIntellitype.java:114)
at com.melloware.jintellitype.JIntellitype.getInstance(JIntellitype.java:174)
at CaptureScreen.registerHotkeys(CaptureScreen.java:163)
at CaptureScreen.<init>(CaptureScreen.java:100)
at CaptureScreen.main(CaptureScreen.java:199)
... 5 more
Caused by: java.lang.UnsatisfiedLinkError: C:\Users\B\AppData\Local\Temp: 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 com.melloware.jintellitype.JIntellitype.<init>(JIntellitype.java:99)
... 9 more
I get this error when I run from the command line, however, it does not cause any issues with my program running on my machine, however, on other peoples machines the program will not run at all.
I have never come across this error before and fairly confused.. mostly that it runs fine on my machine, but not on others even though it throws this error on both.
This is a classpath error. Its likely that you have it set up right for compile time but not runtime. Make sure that either your jar is in the right location and/or that you've set your classpath to include the jar.
Go to the Jintellitype website, download the source, add it to your download folder and then move the .dll files into the folder with the Jitellitype classes after building the project

Java - Library path error

I'm trying to start my java game but I have some troubles with the java command line:
Here is what I type:
C:\>java -Djava.library.path=%cd%\lib -jar game.jar
And here is what I got:
Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
at com.game.Main.main(Main.java:7)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
... 1 more
I can start my game with Eclipse (With Run as Java Application) but after the menu I got the following error:
Exception in thread "Thread-5" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.lwjgl.Sys$1.run(Sys.java:72)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:65)
at org.lwjgl.Sys.loadLibrary(Sys.java:81)
at org.lwjgl.Sys.<clinit>(Sys.java:98)
at org.lwjgl.opengl.Display.<clinit>(Display.java:129)
at com.game.displaygui.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
lwjgl.jar has been put into the folder \lib.
Could you explain me with I got that?
Thanks.
This because lwjgl library is made by two components:
the .jar file which contains Java code
and the native binary library (which can be .so or .dll or .dylib according to your OS)
The first error you are getting is because you are setting the library path, that should contain the native library, but it does contain the .jar. So you get a java.lang.NoClassDefFoundError because you should set either the library path to the folder that contains native library, either the classpath to contain the real lwjgl.jar file.
The second error that you get with Eclipse is a successive step: your classpath contains the jar library but it is not able to find the native library attached to it, you can fix it in the following way:
You should specify explicitly which lib files to include (seperated by ;) :
-cp %cd%\lib\lwjdl.jar;%cd%\lib\<another-lib>.jar
Don't be tempted to use the wildcard * as it will cause more harm than good (from previous experience :))
You use the java.library.path option to specify the location of native libraries to load. In the location pointed to by that option you would place all dll or .so files required by LWJGL. On the other hand, you need to make sure that all required JAR files are on your classpath, via the -classpath option. Currently, you have your JAR files in the wrong directory.
In Eclipse, if you using maven.
Add the following to the project "Run" : "VM options" .
-Djava.library.path=yourpath/youproject/java/target/natives

Exporting project with libraries to runnable jar from Eclipse

I was trying to export a test of a game I am working on(that uses the Slick library), to send to my partners who lack any IDE, all went well with the export in eclipse, but when I try to run it from command prompt, this is what I get in return.
C:\Users\Noah\Desktop>java -jar test.jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:95)
at org.lwjgl.Sys.<clinit>(Sys.java:112)
at org.lwjgl.opengl.Display.<clinit>(Display.java:141)
at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:39)
at java.security.AccessController.doPrivileged(Native Method)
at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:36)
at org.nor.Main.main(Main.java:16)
... 5 more
C:\Users\Noah\Desktop>
Any idea what is going wrong?
NOTE: The project runs perfectly fine in eclipse.
You should read up on a "get started" guide on slick if you are going to use it. Slick has several dependencies who use dll's to communicate with opengl. You need to specify where those dll's are kept so these dependencies can load the dll's. I found this link that might help you do that..
You also need the native lwjgl library and point to it. The Export Jar functionality do not handle this.
Read up on the lwjgl manual for how to do this.
You have to add your jars either to:
the classpath in your java invocation
the Manifest.mf of your main jar
Java won't automatically load your jars until they are in one of these locations.
Try with File -> Properties -> Java Build Path -> Order and Export

Categories