Error loading native library runtime - JAVA

1.7k views Asked by At

I am getting this error + >

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    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.Music.<init>(Music.java:128)
    at org.newdawn.slick.Music.<init>(Music.java:74)
    at com.meteor.breaker.AudioPlayer.load(AudioPlayer.java:21)
    at com.meteor.breaker.Game.<init>(Game.java:35)
    at com.meteor.breaker.Game.main(Game.java:55)
C:\Users\Hardi\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)

I have searched this for a day and couldn't find any working solutions.

I am using lwjgl and it's native libraries are in path

"F:\Khushit Java\Meteor Breaker\lib\windows"

In the windows folder lwjgl.dll is present.

I get over to a VM option:- which was to write

-Djava.library.path="F:\Khushit Java\Meteor Breaker\lib\windows"

This works for running it on ide. but it is not working when i run the jars.

So , I come up with a solution :- to load libraries runtime:-

System.setProperty("java.library.path",<path>);

   static{
                     File l = new File("lib/windows");
                    System.setProperty("java.library.path",l.getAbsolutePath());
                    System.out.println("static:" + System.getProperty("java.library.path"));

                }

Here the real problem comes

if I print System.getProperty("java.library.path") with vm(First method) option I get path :

F:\Khushit Java\Meteor Breaker\lib\windows

and if I print System.getProperty("java.library.path") with runtime linking(second method) I also get the same path:

F:\Khushit Java\Meteor Breaker\lib\windows

Which just means that java.library.path is okay then also i am having the error.

0

There are 0 answers