Search code examples
netbeanslwjgldistributionjava.library.path

How do I distribute a LWJGL jar?


I need help, I followed the following tutorial on setting up my project.

http://lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_NetBeans

And I added the following run command

-Djava.library.path='C:\Program Files (x86)\Java\lwjgl-2.8.3\native\windows'

And my project wors great in netbeans, however I can't distribute my application as I double click the jar I recieve a noClassDefFound exception.

My dist folder contains the following 2 files, no natives.

/dist/Engine.jar /dist/lib/lwjgl.jar

I am sure this is due to my natives not being included in my dist folder, I have tried searching the net and I have yet to find a solution that works, Please any help you can give me would be great, thanks.


Solution

  • I found a solution to my issue, I thought I would share it with others, as a lot of people seemed to have suffered like myself.

    I was receiving the following exception on run,

    Exception in thread "main" java.lang.NoClassDefFoundError: engine2D/engine/Engin
    e
            at Engine2D.Game.<init>(Game.java:42)
        at Engine2D.Game.main(Game.java:48)
    Caused by: java.lang.ClassNotFoundException: engine2D.engine.Engine
            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)
            ... 2 more
    

    This was due to case-sensitivity which was ignored by netbeans, so whenever

    engine2d.engine.Engine 
    

    was invoked it referenced the following.

    Engine2D.engine.Engine
    

    But when ran locally, I hope this helps others and I can get back to working on my game.

    Thanks Gary