Call to com.jme3.system.lwjgl.LwjglTimer throws Exception when running distibution jar

import com.jme3.system.lwjgl.LwjglTimer;
public static LwjglTimer timer = new LwjglTimer();

for some reason my code runs fine in the SDK but when I build and clean my project: running the jar gives 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:72)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:96)
at org.lwjgl.Sys.(Sys.java:117)
at com.jme3.system.lwjgl.LwjglTimer.(LwjglTimer.java:59)
at testerPackage.Main.(Main.java:47)

… this is a picture of the libraries i load.
48%20PM

I have never needed to use that class before. Why are you?

As an aside, the distribution may be using a different lwjgl version.

Isn’t com.jme3.system.Timer an abstract class? I found lwjgltimer to be the only child with a method to get time in seconds.

I use the timer in my project to get the current time in my simpleupdate loop and compare that to to the time of creation n of a certain type of static that can spawn to time a deletion after a certain amount of time.

Why would the dist be using a different version of lwjgl if the same libraries as the sdk are used during building?

thanks

Personally I would use an appstate and accumulate the time until it reached my limit. That would be the JME way.

private float accumulatedTime = 0;

@Override
public void update(float tpf) {
    accumulatedTime += tpf;

    if (accumulatedTime > 5) { // 5 seconds
        doSomething();
    }
}

I’m not saying it is - but if it found the class during the SDK run and didn’t in the DIST run - it just begs the question “whats the difference”.

Yeah this would definitely work.:+1: I just find it weird how the class if found while running from the SDK and not from the dist because to my knowledge there should be no difference.

It’s easy. You are not passing the correct class path.
Running from the SDK does that for you, but when you launch the jar, you need to specify all the libraries using -cp .
Some other tools pack all the libraries into the main jar, that’s probably why you don’t know that problem there.

I’ll look into that. Not to sound dumb but how do you specify a classpath for a JME build? The distribution runs when jme3.system.lwjgltimer is not included. The problem is specific to that error.

How are you building? Most build tools have a way to specify a classpath that is embedded in the .jar this will usually include paths to external jars relative to thelaunch location of the application.

If you move the compiled jar, you must also make sure that copies of all the required jars exist in the proper relative locations.