Is there a chance to build working JAR with Maven?
Posted by ChazAshley on Apr 14, 2015; 10:39am
URL: https://forum.jogamp.org/Is-there-a-chance-to-build-working-JAR-with-Maven-tp4034295.html
Hello.
I have wrote a simple JOGL application.
public class Main implements GLEventListener {
private GLU glu;
private GLUT glut;
private GL2 gl;
public static void main(String[] args) {
GLProfile glProfile = GLProfile.getDefault();
GLCapabilities capabilities = new GLCapabilities(glProfile);
GLWindow window = GLWindow.create(capabilities);
window.setTitle("JOGL test");
window.setSize(1024, 720);
window.setVisible(true);
window.addWindowListener(new WindowAdapter() {
@Override
public void windowDestroyed(WindowEvent e) {
System.exit(0);
}
});
window.addGLEventListener(new Main());
FPSAnimator fpsAnimator = new FPSAnimator(window, 60);
fpsAnimator.start();
}
@Override
public void init(GLAutoDrawable drawable) {
glu= GLU.createGLU(drawable.getGL().getGL2());
glut=new GLUT();
gl=drawable.getGL().getGL2();
}
@Override
public void dispose(GLAutoDrawable drawable) {
}
@Override
public void display(GLAutoDrawable drawable) {
gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
gl.glClearColor(0f, 0f, 0f, 0);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(5, 5, 5, 0, 0, 0, 0, 1, 0);
gl.glColor3f(0.6f,0.6f,0.6f);
glut.glutSolidCube(1);
}
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
gl.glViewport(0,0,1024,720);
gl.glMatrixMode(gl.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(40,(float)1024/720,0.1f,3000);
gl.glMatrixMode(gl.GL_MODELVIEW);
}
It's really simple. In IDE (Intellij IDEA) it works fine. But when I have built a JAR file using Maven and tried to run it - i got an exception.
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: D:\IdeaProjects\jogl-test\target\gluegen-rt.dll
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:596)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:63)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:95)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:459)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:421)
at com.jogamp.common.os.Platform$1.run(Platform.java:317)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:287)
at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:146)
at Main.main(Main.java:18)
Okay. Actually I thought that Maven will download all needed libraries.
Then i have placed gluegen-rt.dll into a folder with JAR file and tried again to run it, but got another exception.
Exception in thread "main" java.lang.UnsatisfiedLinkError: jogamp.common.os.MachineDataInfoRuntime.getPointerSizeInBytesImpl()I
at jogamp.common.os.MachineDataInfoRuntime.getPointerSizeInBytesImpl(Native Method)
at jogamp.common.os.MachineDataInfoRuntime.getRuntimeImpl(MachineDataInfoRuntime.java:129)
at jogamp.common.os.MachineDataInfoRuntime.initialize(MachineDataInfoRuntime.java:50)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:339)
at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:146)
at Main.main(Main.java:18)
So is there a problem with libraries? How to make it run?
I use this dependencies.
<dependency>
<groupId>org.jogamp.gluegen</groupId>
<artifactId>gluegen-rt</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.jogamp.jogl</groupId>
<artifactId>jogl-all</artifactId>
<version>2.3.1</version>
</dependency>