Reputation: 20555
I have a Java program (using JavaSE-1.6).
When i execute the program in eclipse there is no problem and i get the following:
But when i export it to an executable jar and run it i get the following:
Has anyone ever experienced anything like this?
Exception in thread "main" java.lang.NoSuchMethodError
at org.eclipse.jdt.internal.jarinjarloader.RsrcURLConnection.getInputStr
eam(RsrcURLConnection.java:43)
at java.net.URL.openStream(Unknown Source)
at sun.misc.URLClassPath$Loader.getResource(Unknown Source)
at sun.misc.URLClassPath.getResource(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.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:56)
Upvotes: 0
Views: 875
Reputation: 328614
The most common reason for this behavior is that you have two different versions of the same JAR on the classpath.
Depending on how you start your application, one or the other takes precedence and shadows the other.
If you use Maven, then the maven-duplicate-finder-plugin is for you.
Upvotes: 0
Reputation:
I encourage you to carefully read this page, it's just a very basic information about jar file: http://docs.oracle.com/javase/tutorial/deployment/jar/view.html
There is nothing special about jar file, in fact it is just an archive, like *.zip or *.rar. What java
bin does is actually just to process the jar file based on the metadata inside and then run the classes inside.
A few things that you can do to debug:
java -jar yourjarfile.jar
Upvotes: 1