5 Replies Latest reply: Feb 23, 2010 11:55 PM by 793415 RSS

    executable jar file not opening properly

    843804
      Hi,
      I have a java application using Java OpenGL canvas and Swing components in seperate panels. When I double click my executable jar, the swing components work fine, but I am not able to see the OpenGL canvas panel.
      Can anyone explain why this is happening and how to solve it?
      Thanks in advance.
        • 1. Re: executable jar file not opening properly
          793415
          bindyas wrote:
          ..I have a java application using Java OpenGL canvas and Swing components in seperate panels. When I double click my executable jar, the swing components work fine, but I am not able to see the OpenGL canvas panel.
          When debugging Jar files, don't double click them to open them. The error output is not visible, so you are 'fighting with one arm tied behind your back'. Instead, launch them from the command line, where errors are visible. To launch a Jar from the command line, navigate to the directory with the Jar and type..
          prompt: java -jar thejarname.jar
          Can anyone explain why this is happening and how to solve it?
          It is possibly because the OpenGL classes are not on the run-time classpath of the application, but we will know more once you have copy/pasted the [exact output|http://pscode.org/javafaq.html#exact] you get from running it in the command line.
          • 2. Re: executable jar file not opening properly
            843804
            Thank you for the help.

            You are right. The jogl jar was not included in the classpath. The error was as follows.

            Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.sun.opengl.impl.windows.WindowsGLDrawableFactory
            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.GLJPanel.initialize(GLJPanel.java:889)
            at javax.media.opengl.GLJPanel.paintComponent(GLJPanel.java:488)
            at javax.swing.JComponent.paint(Unknown Source)
            at javax.swing.JComponent.paintToOffscreen(Unknown Source)......

            I created a .bat file and added jogl.jar to classpath. Something like below.

            java -Xmx512m -classpath "%JOGL_TOP%\lib\jogl.jar;%JOGL_TOP%\lib\gluegen-rt.jar;<myJar.jar>" <main class name>

            Though I had included the jogl.jar in manifest.mf, it seems to have no effect.

            Contents of my manifest.mf

            Manifest-Version: 1.0
            Class-Path: gluegen-rt.jar jogl.jar
            Main-Class: jp.co.fpec1.trajectory_viewer.TrajectorySimulate

            I am glad that the .bat file works. If the jar could be directly executable, would be better.
            • 3. Re: executable jar file not opening properly
              793415
              bindyas wrote:
              Thank you for the help.
              You're welcome.
              ...The jogl jar was not included in the classpath. The error was as follows.

              Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.sun.opengl.impl.windows.WindowsGLDrawableFactory
              ...
              Though I had included the jogl.jar in manifest.mf, it seems to have no effect.

              Contents of my manifest.mf

              Manifest-Version: 1.0
              Class-Path: gluegen-rt.jar jogl.jar
              Main-Class: jp.co.fpec1.trajectory_viewer.TrajectorySimulate
              Out of curiosity.
              1) Does that manifest have an entirely blank line at the end of it? (It should have one, or it won't work correctly)
              2) How is the manifest being generated or edited? (E.G. Windows notepad, Ant..)
              I am glad that the .bat file works. If the jar could be directly executable, would be better.
              OK - let's focus on getting it to work as a 'double click' Jar, since that is much better, but for the moment continue with the command line, for the extra information it provides.

              When you navigate to the same directory as the main Jar, and type something like..
              prompt: dir
              ..what is the output?

              I figure it should show at least 3 Jars in that directory.
              • 4. Re: executable jar file not opening properly
                843804
                +1) Does that manifest have an entirely blank line at the end of it? (It should have one, or it won't work correctly)+

                Yes, It has an empty line at the end of it.

                +2) How is the manifest being generated or edited? (E.G. Windows notepad, Ant..)+

                I created a manifest file, using Eclipse. On my project, I did an export Jar, create Manifest file. Then I edited the manifest file. Export jar again, this time, use existing manifest file. Long way round, but I was afraid of typo errors.

                +"When you navigate to the same directory as the main Jar, and type something like.."+

                There was only one jar. Only my project jar. I was missing jogl.jar and gluegen-rt.jar.
                But even after adding the jar file, in the same directory as my project jar, i get the following error at command prompt.

                Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.sun.opengl.impl.windows.WindowsGLDrawableFactory
                at java.lang.Class.forName0(Native Method)
                at java.lang.Class.forName(Unknown Source)
                at javax.media.opengl.GLDrawableFactory.getFactory(GLDrawableFactory.java:106)......
                • 5. Re: executable jar file not opening properly
                  793415
                  Hmmm.. I'm a bit at a loss as to why it is not working.

                  Do the command ..
                  prompt: jar -tvf jogl.jar
                  prompt: jar -tvf gluegen-rt.jar
                  .. and check that the WindowsGLDrawableFactory.class is present in one of them.