2 Replies Latest reply on Oct 19, 2012 3:34 PM by gimbal2

    Program not running as executable jar

      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.
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
      Caused by: java.lang.NullPointerException
      at Game.MusicDataAccessor.getCategories(MusicDataAccessor
      at Game.GamePanelGUI.<init>(GamePanelGUI.java:54)
      at Game.MainFrame.<init>(MainFrame.java:52)
      at Game.GameLibraryMain.main(GameLibraryMain.java:35)
      ... 5 more

        • 1. Re: Program not running as executable jar
          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
            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.