2 Replies Latest reply: Oct 19, 2012 10:34 AM by gimbal2 RSS

    Program not running as executable jar

    829065
      I have written a program and it runs fine when run through eclipse. I exported everything to an executable jar file. When I double click the jar to run it, it does not run. So I ran it via cmd with -jar and have received the errors below. What do these mean? What can I do to get executable jar working.

      Microsoft Windows [Version 6.1.7601]
      Copyright (c) 2009 Microsoft Corporation. All rights reserved.

      C:\Users\Matthew>java.exe -jar "C:\users\matthew\desktop\thegame.jar"
      Exception in thread "main" java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
      der.java:58)
      Caused by: java.lang.NullPointerException
      at Game.MusicDataAccessor.getCategories(MusicDataAccessor
      .java:63)
      at Game.GamePanelGUI.<init>(GamePanelGUI.java:54)
      at Game.MainFrame.<init>(MainFrame.java:52)
      at Game.GameLibraryMain.main(GameLibraryMain.java:35)
      ... 5 more

      C:\Users\Matthew>
        • 1. Re: Program not running as executable jar
          969557
          It looks to me that You can in fact launch the jar successfully but it runs to a problem during execution. If the same code works launched within Eclipse, I would suspect the problem is caused by differences between these two runtime environments : Eclipse environment and command line environment.

          To solve the problem, I propose investigating what happens in line 63 of MusicDataAccessor.java, as that is the place where the stack trace indicates the NullPointerException. You might send that line of code here to get hints on what can go wrong.

          One thing I'd like to mention is that when you export a project from Eclipse as Runnable JAR file, it is exported with selected Eclipse launch configuration and Eclipse specific launch wrappers. To create a standard executable JAR file, you can export as JAR file and specify the main class in last screen of the wizard.
          • 2. Re: Program not running as executable jar
            gimbal2
            Nice of you to offer help, but this thread is MONTHS old. The OP likely resolved it himself by actually performing some research.

            Better focus your efforts on recent questions.