Hot questions for Using Lightweight Java Game Library in maven

Im unable to successfully add proper dependencies for LWJGL in maven project. I have copied lwjgl dependency tempalte from maven repository, added it to my pom.xml and tried to run basic application from lwjgl.org, without success.

Below you have my pom.xml file, unfortunately when I try to run my first application i get:

I found some sollution that I need to download all jars and attach them as jar library, so I did. File > Project Structure > Librarires > added folder which store all jars for LWJGL, unfortunately this is still not working.

I am trying to setup a LWJGL project using Maven. I am using the example "getting started" source code from the official website.

This includes a few lines accessing LWJGL's manifest attributes, such as a simple version check:

System.out.println("Hello LWJGL " + Version.getVersion() + "!");

This runs without any problems in the Eclipse environment (of course after having built the project with Maven), but when running clean install and then running **-jar-with-dependencies.jar through cmd, the following exception get's thrown:

java.lang.NullPointerException
at org.lwjgl.system.APIUtil.apiGetManifestValue(APIUtil.java:97)
at org.lwjgl.Version.getVersion(Version.java:33)
at HelloWorld.run(HelloWorld.java:43)
at HelloWorld.main(HelloWorld.java:130)

This is because the Manifest object created by APIUtil does not include any attributes - but only in the built version by Maven.

Why is this? Is my pom.xml buggy, or is LWJGL 3.0.0 just not ready for this?

You can see it inside META-INF/MANIFEST.MF of the jar-with-dependencies. This file does not have a "Implementation-Version" property. This is normal: when this executable JAR was created, all the MANIFEST of all dependencies were (rightfully) ignored, only to generate one containing the "Main-Class", just so that the JAR is executable.

The uber-jar cannot contain what is inside each of the dependencies manifest. For example, "Implementation-Version" is a property that is present in the manifest of multiple libraries, so which one should it keep? (There can be only one Manifest at the end, in the uber-jar). So the issue comes up because we're making an executable JAR, which can only have 1 Manifest so it cannot aggregate all the properties inside each of the dependencies manifest.

There are 2 possible solutions:

Ignore it. After all, this is not really an error.

Don't make an executable jar by embedding all the dependencies inside a single JAR, but create a ZIP assembly with each dependencies inside a lib folder: this way, each Manifest will be kept. This is done by telling the maven-jar-plugin to add a Manifest entry for the main class with the addition of the classpath and creating a custom assembly descriptor.

I want to include LWJGL via Maven in my project. I get the .jar files but the natives are not in the classpath.

With the help of google I found out that I should use mavennatives in order to automatically extract and copy the natives. However mavennatives will only find the natives that start with native- and the LWJGL-natives all have names like {artifactId}-{version}-natives-{os}.jar.

Question: How can I get Maven to import the dependencies with the proper names and extract these natives?

This plugin unpacks every dependency with a classifier beginning with natives-.

That's exactly your use case, the documentation points to the classifier element, which in your case is natives-linux or natives-windows.

Accordingo to the documentation, theses cases will be handled:

This are the default values, when enabling separateDirs the plugin will unpack each native dependency to a subdir of the nativesTargetDir named like its classifier (for example: natives-windows will go to target/natives/windows)

Indeed the whole library's jar is in the form of {artifactId}-{version}-natives-{os}.jar but in Maven the classifier is exactly the string between the {version} and the extension of the file: in this case natives-{os}, which starts by natives and as such is handled by the library.

I've imported an existing multi-module Maven project into IntelliJ. The parent project itself builds and runs fine, but I'm trying to run one of the modules (a popup viewer window) on its own. When I do, I get this error:

[LWJGL] Failed to load a library. Possible solutions:
a) Add the directory that contains the shared library to -Djava.library.path or -Dorg.lwjgl.librarypath.
b) Add the JAR that contains the shared library to the classpath.
[LWJGL] Enable debug mode with -Dorg.lwjgl.util.Debug=true for better diagnostics.
[LWJGL] Enable the SharedLibraryLoader debug mode with -Dorg.lwjgl.util.DebugLoader=true for better diagnostics.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to locate library: lwjgl.dll

I'm not sure how to fix this, and I'm confused on how the overall project builds and runs fine, but the module has issues running. lwjgl is included in the pom.xml, so shouldn't Maven take care of this dependency?

Answer:

So my problem turned out to be that I'm on a Windows computer, but the project I've been given has its pom.xml configured so only lwjgl native-macos jars are downloaded. I fixed this by editing the main pom.xml to include two separate profiles for mac vs. windows and using them in the classifier for the lwjgl dependencies.

I've started developing a 3D java game engine using OpenGL in Codenvy IDE, using Maven. I've configured to run Java 8, and I've set up the dependencies in pom.xml that is required for LWJGL. However, when I run a test window, I get a NoClassDefFoundError. I'm unsure why this happens, considering Maven is configured to store all .Jar dependencies into one filem so accessing them shouldn't be a concern. All the files have downloaded properly into the External Packages directory in my Codenvy project.