Error while executing jar files - java

Why do I get this error when I try to open a .JAR file from cmd?
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at sqlprojectgestor.Gestor.initComponents(Gestor.java:311)
at sqlprojectgestor.Gestor.<init>(Gestor.java:28)
at sqlprojectgestor.Gestor.lambda$main$0(Gestor.java:1017)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(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)
I try to run the .jar file with double click but it won't open...

I suspect your issue is caused by not including images in your JAR. Please see this question on how to do that: It may be that you don't include images as resources in your JAR. See this question: Add image to JAR Java

Related

com.mysql.jdbc.Driver Error when I run the Jar File although that exists in my Build Path

I have created a java swing application with rmi and export als Jar File the Client.Althout that my Jar File is runing with the first mySql connection comming the following Error Message. Everything works perfect when I compile and run the program in Eclipse, the Error comes only as a Jar file. So far I have searched here and generell, have seen that the problem has with my Build Path to do, althougth that the mysql-connecor-java-5.1.37-bin.jar inlcuded in Build Path and in the classpath.
The Error message:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at util.ConnectDB.getConnection(ConnectDB.java:14)
at clientValantis.LoginForm.<init>(LoginForm.java:59)
at clientValantis.Main$1.run(Main.java:16)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(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) java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at util.ConnectDB.getConnection(ConnectDB.java:14)
at clientValantis.LoginForm.<init>(LoginForm.java:59)
at clientValantis.LoginForm$1.run(LoginForm.java:41)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(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)
then my Build Path is like this :
have to inlcude more jar into my build path pr what I m doing wrong when I export the Jar File and comes this Error. I m doint it in Eclipse
Export -> JAR file -> Select the destination -> Generate the manifest file ->Select the Main class -> Finish
and here my classpath
The MANIFEST.MF that generated from Eclipse only has this inside
Manifest-Version: 1.0 Main-Class: clientValantis.Main

jar file not performing all feature in another application with stacktrace

I am creating a standalone application in java. I create a jar file of that application by Netbeans IDE; .jar working fine in my system but not working all feature in another system. I am using jar library in my application. Exception is showing Noclassdeffound. This application scan qr code. This works fine in my system but even webcam in not open in another system. Please help me. Thanks.
stacktrace is as follows
C:\Users\Shubham\Downloads>java -jar JavaApplication1(2).jar
h3llo44444
hello world1111=null
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/githu
b/sarxos/webcam/WebcamPanel
at javaapplication1.MainFrame.jButton2ActionPerformed(MainFrame.java:248
)
at javaapplication1.MainFrame.access$100(MainFrame.java:33)
at javaapplication1.MainFrame$2.actionPerformed(MainFrame.java:104)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
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.ClassNotFoundException: com.github.sarxos.webcam.WebcamPane
l
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 39 more
Noclassdeffound error is thrown when the Java Virtual Machine (JVM) or an instance of the ClassLoader class tries to load the definition of a class, but the definition could not be found.where a class has a dependency on some other class and that class is not accessible.
In short at if you have used any external jar file than that jar file will be required at compile time as well at Run-time also in your case it seems that JVM is unable to find external jar file that contains WebcamPanel class at run time. so you need to pack that Jar file also with your application's Jar file.
for how to add External Jar file in your project you can refer
How can I include external jar on my Netbeans project

Error text file generates when creating an exe file using exe4j

My program is created using Netbeans and I need to make a .exe to make a setup file using innosetup, so I used exe4j to make the exe. This is what generates in a text file when all the steps are done.
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:
org/netbeans/lib/awtextra/AbsoluteLayout
at app.initComponents(app.java:78)
at app.<init>(app.java:39)
at Main$1.run(Main.java:32)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(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.ClassNotFoundException:
org.netbeans.lib.awtextra.AbsoluteLayout
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 17 more
Thank you.
Verify that org.netbeans.lib.awtextra.AbsoluteLayout is available in the classpath at runtime. You can locate AbsoluteLayout.jar in the NetBeans distribution, as shown below:
$ find . -name \*AbsoluteLayout\*
./Contents/Resources/NetBeans/java/modules/ext/AbsoluteLayout.jar
./Contents/Resources/NetBeans/java/sources/org/netbeans/lib/awtextra/AbsoluteLayout.java
…

Error when running applet with Slick2D

I have been trying to get a slick application to work on a website for awhile now, and I have the HTML code correct, I know that for sure, however I am getting an error from the applet saying this:
Initializing real applet
Mon May 20 17:07:24 EDT 2013 ERROR:Game.GameBoard
java.lang.ClassNotFoundException: Game.GameBoard
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.newdawn.slick.AppletGameContainer.init(AppletGameContainer.java:123)
at org.lwjgl.util.applet.AppletLoader.switchApplet(AppletLoader.java:1330)
at org.lwjgl.util.applet.AppletLoader$2.run(AppletLoader.java:909)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(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)
This occurred while 'Initializing real applet'
Unable to create game container
java.lang.RuntimeException: Unable to create game container
at org.newdawn.slick.AppletGameContainer.init(AppletGameContainer.java:147)
at org.lwjgl.util.applet.AppletLoader.switchApplet(AppletLoader.java:1330)
at org.lwjgl.util.applet.AppletLoader$2.run(AppletLoader.java:909)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(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)
Done loading
I understand that the applet won't start. I've done some excessive searching to find the answer, however, I have found none. I do not use a GameState, but use a BasicGame. Most tutorials I've read say to just write it like a normal application. So I'm confused as to how to get this to work properly. It doesn't seem like I need to make any new changes, but that I can't figure out what exactly I need to do.
Any help would be appreciated.
Thank you!
It seems as if the error happened as a naming issue.

java.lang.NoClassDefFoundError: org/json/simple/JSONObject running outside of Netbeans IDE

Similar questions have been asked here about this error, but I have tried most of the solutions and still get the same error message. I'm using json-simple library in my java app. I have included the json-simple-1.1.1.jar file in my library. Running through Netbeans works perfectly. When I try running it through the command line "java -jar " I get the following error. Even "java -cp json-simple-1.1.1.jar -jar still give the same error.
nullException in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/json/simple/JSONObject
at gui.keo_synopticx.jb_save_configMouseClicked(keo_synopticx.java:5318)
at gui.keo_synopticx.access$6000(keo_synopticx.java:49)
at gui.keo_synopticx$60.mouseClicked(keo_synopticx.java:3358)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(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.ClassNotFoundException: org.json.simple.JSONObject
at java.net.URLClassLoader$1.run(Unknown Source)
I may be missing a dependency for json-simple-1.1.1? Any advice would be greatly appreciated.
The org/json/simple/JSONObject class is definitely in the jar file.
The only reason for the problem I can think of is that you did not specify the jar file path, and that the jar is not in the same directory as your execution directory.
To solve this issue you should precise your classpath on the terminal:
syntaxe:
java -classpath <your_archive.jar> [<package>.]<Class_name>
don't forget the package if the class belongs to one.

Categories

Resources