[SOLVED] joml.jar troubles if I run my project from command line

Started by sc, September 13, 2019, 07:08:21

Previous topic - Next topic

sc

I've started using lwjgl a couple of weeks ago, and everything was going well until I wanted to run my project from the command line.

I get the error :
D:\nb\OGL_Engine\dist>java -jar OGL_Engine.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/joml/Vector3f
        at be.tpfc.Game.<init>(Game.java:40)
        at be.tpfc.engine.Engine.<init>(Engine.java:48)
        at be.tpfc.Main.main(Main.java:24)
Caused by: java.lang.ClassNotFoundException: org.joml.Vector3f
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 3 more


... as if it cannot find the joml.jar ?

I'm using Netbeans10 on Windows10 with lwjgl-release-3.2.3 (and joml.jar from that release) and AdoptOpenJDK\jdk-11.0.4.11-hotspot.
I've spent a couple of hours on it already, but I have no idea what I'm doing wrong ... ???

KaiHH

You only have a single jar file (OGL_Engine.jar) in the classpath. Do you shade all jars into this OGL_Engine.jar file or do you use the "Class-Path" MANIFEST.MF entry to specify all other (LWJGL and JOML) jars?

sc

Quote from: KaiHH on September 13, 2019, 08:25:21
You only have a single jar file (OGL_Engine.jar) in the classpath. Do you shade all jars into this OGL_Engine.jar file or do you use the "Class-Path" MANIFEST.MF entry to specify all other (LWJGL and JOML) jars?

I'm afraid you lost me there ... :-[

If I open up the OGL_Engine.jar, I can see that there are no other jars included. (Out of curiousity : how would I do that ?) But, there is a manifest.mf file.
No other dependencies specified though.
I'll Google some more to find out how to add everything. Somehow, I thought the IDE was going to do that for me ...
Thanks for steering me in the right direction !

EDIT : OK, it's now a couple of days later and I finally figured out how to do this.
It's all quite easy, once you know what you're supposed to do. =)
Since Maven is integrated into Netbeans, I've recreated my project as a Maven project. It is now also quite easy to keep track of all dependencies (using the pom.xml from the lwjgl customized download).
To create a fat jar, I'm using the maven-shade-plugin. I also have this plugin modify the MANIFEST file, so that the jar becomes an executable jar.