Exporting Java project as runnable Jar: not doing anything - java

So I have a problem with exporting my eclipse project.
The project works perfectly when running it inside eclipse, but when exporting it, it doesn't do anything.
I can't post a third link since I have less than 10 reputation, but in there I chose my "main" as launch configuration, and "package required libraries.
When I double click the runnable Jar nothing happens, nothing pops up.. No message nothing.
When I run it using java -jar smergy.jar I receive
`C:\Users\Jean>java -jar Smergy.jar
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at smergy.SmergyMain.<init>(SmergyMain.java:162)
at smergy.SmergyMain$1.run(SmergyMain.java:50)
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.doIntersectionP
rivilege(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)`

Most likely the images are not being packaged into the jar. Or they are not being loaded.
One way to deal with loading resources is using the Toolkit like this:
setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/package1/package2/dump.jpg")));

Related

com.toedter.calendar.jdatechooser error when running setup created using launch4j

iam using launch4j to create a .exe file, i created runnable jar file using the export option in the file menu in eclipse.the jar file runs succesfully but whenever i create a setup file in launch4j,the setup is created successfully but when it is run i get the errors in launch4j log
Executing: E:\app.exe
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/toedter/calendar/JDateChooser
at run$1.run(run.java:9)
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$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: com.toedter.calendar.JDateChooser
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)
... 15 more
See the exception:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/toedter/calendar/JDateChooser
at run$1.run(run.java:9)
Whenever your class is not available for the class Loader (ie your .class file) then we will get this exception.
Read the below post for better understanding:
How to solve java.lang.NoClassDefFoundError?

Error java.lang.NullPointerException on a executable

I have created a java application to connect to a MySQL database.
Once through the program install creator I created an .exe .
This executable runs, and the first form is login. When he tries to access the database to confirm the details of login gives this error.
java.lang.NullPointerException
Someone can help me solve this? The path is correct, because if run the .jar the application runs normally.
I apologize for the inconvenience.
Only have this to try explain better my question :S
I'm so sorry... I'm running a executable version from my java aplication.
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at sensores.forms.jTMainMenu.initComponents(jTMainMenu.java:786)
at sensores.forms.jTMainMenu.<init>(jTMainMenu.java:57)
at sensores.forms.jTLoginConsulta.jBLoginActionPerformed(jTLoginConsulta.java:351)
at sensores.forms.jTLoginConsulta.access$000(jTLoginConsulta.java:59)
at sensores.forms.jTLoginConsulta$1.actionPerformed(jTLoginConsulta.java:110)
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 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)
You have an error in this class/line
jTMainMenu.java:786
Seems you tried to load a image in this point of your code, i don't know how you are generating a executable from your java code but this may be the source of the problem. Try to put this image outside of your executable/jar and use a relative path to load the image, like './my_image'.
You also have to take care if your user make a link to your executable, in this case a relative path can't resolve your problem. A simple way to solve this in java is get the source code location.
getClass().getProtectionDomain().getCodeSource().getLocation();
And use this location to find your image.
Please check the line number from the Stacktrace where you are getting the NullPointerException.
it is straight forward to find out the null pointer exception. Object is null or not initialize on which you are calling the method
try{
// add database connection statement here
}catch(Exception e){
e.printstacktrace();
}
// run the program from the command prompt.
// you can print the e.printstacktrace() on the popup as well to get the exception details
If you make a .jar, move that jar somewhere separate from the IDE (i.e. their classpaths), and start the jar, do you receive a NullPointerException?
This can be caused by resources, getResource, getResourceAsStreem, getBundle, as they are not case-sensitive in the Windows file system, but are case sensitive in a jar(and under Linux/MacOS).
(Also File cannot be used for jar resources.)
You might look in the jar with 7zip or so to inspect all paths.
I think it is not getting image icon in defined path
at javax.swing.ImageIcon.<init>(Unknown Source)
I have the following two guesses:
There is a problem with your path or classpath and loading the resource
The lines
at sensores.forms.jTMainMenu.initComponents(jTMainMenu.java:786)
at sensores.forms.jTMainMenu.(jTMainMenu.java:57)
indicate that something is initialized. Usually Swing/AWT uses multiple threads, so you might have a race condition here: The reference to the resource is handed to ImageIcon in your ìnitComponents method before another thread could set the value to something non-null. Try using proper synchronization/locking.

Java applet calling WCF Service fails with noclassdef exception at runtime

I have a java applet which uses a proxy service to a WCF Service to display data. The applet compiles and runs perfectly in Eclipse but when I build and export a Jar file then run it in a html page it fails with
java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException.
I have included jaxrpc.jar in my build path and my jar file contains all necessary classes.
The stack trace seems to be complaining about the line where I instantiate the proxy service from within the applet class. Does anyone know if there is an issue calling WCF service from a java applet?
Stack Trace:
java.lang.RuntimeException: java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.instantiateApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.initAppletAdapter(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException
at ListProducts.ListProducts.<init>(ListProducts.java:25)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter$1.run(Unknown Source)
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.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: javax.xml.rpc.ServiceException
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 27 more
This has been troubling me all day.
I think your issue is loading rpc jar, not call to wcf.
This post can be helpfull:
http://www.coderanch.com/t/259357/Applets/java/Applet-Axis-Client-Errors
It recomemds to sign your jar, verify you can access all your jars via browser, ensure you have all dependent.jars.
If all this will not help - i'd try to solve it as "
NoClassDefFoundError from spplet" issue.
Ok. I got this working by doing several things:
First I had to sign several of the jar files I was using:
jaxrpc.jar
axis.jar
commons-discovery-0.2.jar
but not:
javax.wsdl_1.6.2.v201012040545.jar
org.apache.commons.logging_1.0.4.v201101211617.jar
Secondly - all these files had to exist in the same directory as the html page, as I didn't specify a directory in codebase property for the applet tag.
Thirdly, within my main applet (ListProducts.class) I had to use AccessController.doPrivileged() around the code that first calls the proxy service:
EDIT: This step may not be necessary, as it now seems to work when I remove the doPrivileged block.
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
try {
//instantiate proxy service and make rpc's
//do other stuff with results...
} catch (RemoteException e) {
// catch error
}
return null;
}
});
This combination of things got the java applet doing what it should. It was a painful slow process to discover which jar files were missing and then signing the appropriate ones.

My code is working fine in Netbeans but throws exception when running the jar

My code is working fine without any errors when running in Netbeans. If I make a clean build then executing jar file it crashes without any errors visable (swing application).
When I execute the jar file in command line I get this error:
D:\xxx>java -jar ScreenShotUploader.jar
Exception in thread "AWT-EventQueue0"java.lang.NoClassDefFoundError: com/melloware/jintellitype/JIntellitype
at screenshotuploader.HKRegistering.registerHK(HKRegistering.java:13)
at screenshotuploader.ScreenShotUploaderJFrame$3.run(ScreenShotUploaderJ
Frame.java:69)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(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: com.melloware.jintellitype.JIntellitype
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)
... 16 more
What is the problem?
seems like you are referencing some library. did you tell netbeans to export referenced jars into your jar?

PersistenceException with Umlaut in path

I experienced an odd behavior with a java desktop application that uses Toplink essentials as persistence provider.
I have a single directory containing all I need for my application: a jar, a lib folder and a JavaDB database. The whole directory is self-contained (I copied it several times without problems, even between different computers).
Today I wanted to copy once more, but my target folder contained a german Umlaut ü (html: ü).
Starting my application failed, with an exception that made it hard to find the reason why (see below).
Of course I know the old naming conventions, but I thought we already left that behind. So my question is, if there is a way to make it run independent of directory naming. It's important since I want to give the application to clients and have only little influence on install dirs.
System: Windows 7, JavaDB 10.5.3
Thanks in advance for your help!
SCHWERWIEGEND: Application class jlabps.JLabPSApp failed to launch
javax.persistence.PersistenceException: No Persistence provider for EntityManage
r named JLAPS_EMB: The following providers:
oracle.toplink.essentials.PersistenceProvider
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
Returned null to createEntityManagerFactory.
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.
java:154)
at jlabps.JLabPSView.initComponents(JLabPSView.java:401)
at jlabps.JLabPSView.<init>(JLabPSView.java:47)
at jlabps.JLabPSApp.startup(JLabPSApp.java:71)
at org.jdesktop.application.Application$1.run(Application.java:171)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$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)
Exception in thread "AWT-EventQueue-0" java.lang.Error: Application class jlabps
.JLabPSApp failed to launch
at org.jdesktop.application.Application$1.run(Application.java:177)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$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: javax.persistence.PersistenceException: No Persistence provider for E
ntityManager named JLAPS_EMB: The following providers:
oracle.toplink.essentials.PersistenceProvider
oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider
Returned null to createEntityManagerFactory.
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.
java:154)
at jlabps.JLabPSView.initComponents(JLabPSView.java:401)
at jlabps.JLabPSView.<init>(JLabPSView.java:47)
at jlabps.JLabPSApp.startup(JLabPSApp.java:71)
at org.jdesktop.application.Application$1.run(Application.java:171)
... 14 more
Odd. What JVM are you using?
Ensure you have the latest TopLink Essentials patch, I remember an issue with spaces, but not Umlats.
You could also try upgrading to EclipseLink and see if the same issue occurs, if it does please log a bug.

Categories