launching jar works, executing from cmd doesn't

hello

i’ve encountered strange problem:
i’ve built my app, and when i run dist version for my platform (i586) by double clicking the jar file, it works fine.
but when i run the same app by entering java -jar “path\to\jar\my_jar.jar” it runs with errors:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.Ill
egalArgumentException: argument type mismatch
        at com.sun.opengl.impl.JAWT_DrawingSurfaceInfo.newPlatformInfo(JAWT_Draw
ingSurfaceInfo.java:86)
        at com.sun.opengl.impl.JAWT_DrawingSurfaceInfo.platformInfo(JAWT_Drawing
SurfaceInfo.java:52)
        at com.sun.opengl.impl.windows.WindowsOnscreenGLDrawable.lockSurface(Win
dowsOnscreenGLDrawable.java:189)
        at com.sun.opengl.impl.windows.WindowsOnscreenGLContext.makeCurrentImpl(
WindowsOnscreenGLContext.java:57)
        at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:134)

        at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1
82)
        at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.
java:412)
        at javax.media.opengl.GLCanvas.display(GLCanvas.java:244)
        at javax.media.opengl.GLCanvas.paint(GLCanvas.java:277)
        at sun.awt.RepaintArea.paintComponent(Unknown Source)
        at sun.awt.RepaintArea.paint(Unknown Source)
        at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.sun.opengl.impl.JAWT_DrawingSurfaceInfo.newPlatformInfo(JAWT_Draw
ingSurfaceInfo.java:83)
        ... 20 more

what am i doing wrong? why in one case it works, and in other doesn’t? all dlls are in place…

Hi,

Are you sure you don’t put any jogl dll/so files into the jre or jdk directories? It may be the root of your problem…

yes, I’m sure. it caused me a lot of problems before, so i don’t do it anymore :slight_smile:
in general: i would like to create a distributable app, that can be downloaded as a jar, and launched as a standalone app on clients’ machines.
so, test environment in this case would be a standard PC, windows box for example, with jre installed, and nothing else.

furthermore, when i run my app from command line on a different machine, i get following exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jogl in java.library.path
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at com.sun.opengl.impl.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:189)
        at com.sun.opengl.impl.NativeLibLoader.access$000(NativeLibLoader.java:49)
        at com.sun.opengl.impl.NativeLibLoader$DefaultAction.loadLibrary(NativeLibLoader.java:80)
        at com.sun.opengl.impl.NativeLibLoader.loadLibrary(NativeLibLoader.java:103)
        at com.sun.opengl.impl.NativeLibLoader.access$200(NativeLibLoader.java:49)
        at com.sun.opengl.impl.NativeLibLoader$1.run(NativeLibLoader.java:111)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.opengl.impl.NativeLibLoader.loadCore(NativeLibLoader.java:109)
        at com.sun.opengl.impl.windows.WindowsGLDrawableFactory.<clinit>(WindowsGLDrawableFactory.java:60)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:106)
        at javax.media.opengl.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:520)
        at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:131)
        at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:90)
        at javax.media.opengl.GLCanvas.<init>(GLCanvas.java:83)
        at org.barret.mainFrame.initComponents(mainFrame.java:72)
        at org.barret.mainFrame.<init>(mainFrame.java:41)
        at org.barret.main.main(main.java:19)

and when i run it by double clicking jar file - it runs fine.
i think there might be something wrong with classpath or path settings - different settings when running from cmd, and different when running by launch.

what am i doing wrong?

The problem is, that you don’t have the correct lava.library.path setting. Double clicking a jar implicitely puts the current working directory in the list of valid dll-locations (this is only true for windows, not for other operating systems). So the app will start fine. Calling the executable jar from the command line requires you to add the gluegen and jogl locations to the java.library.path:


java -Djava.library.path="path\to\natives\folder" -jar "path\to\jar\my_jar.jar"

And that is the answer i was looking for.
Thank you very much Mathias! :slight_smile: