Executing jar file throws class not found error - java

Using Eclipse, I am modifying a Java project we have been using for years. a specific class method is typically executed by sending a message through IBM WebSphere MQ. However, I now have a need to develop some new functionality and I need to be able to test it out side the MQ world.
I am able to successfully debug the application in Eclipse, but if I attempt to execute the jar file from a command prompt I receive the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: XMLBuilder/Node
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: XMLBuilder.Node
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)
... 6 more
My build is done using an ant script. This does not include a Class-Path attribute when creating the manifest.
The XMLBuilder.jar file is included in the target jar. Running jar -tf file.jar shows
META-INF/)
META-INF/MANIFEST.MF)
... Omitted for Brevity ...
XMLBuilder.jar
What might I be missing?
Thank you

Related

java lib connect to another lib error

I've created my own jar file which includes javamail-1.4.5 lib. and when I run a batch file that starts the main class I got this error
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Store
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.mail.Store
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)
... 7 more
Press any key to continue . . .
I'm using the following query in batch file
java -cp ../libs/myLib.jar main.Main
The strange thing is that if I run my main class via eclipse I haven't errors.
Can someone help me about why is this happening and what I have to do to solve it?
Fix: java -cp ../libs/mail.jar;../libs/myLib.jar main.Main

jmeter class not found

I am trying to run apache jmeter on my VM but getting this error.
D:\Users\1255592\Desktop\apache-jmeter-3.1\apache-jmeter-3.1\bin>jmeter
java.lang.NoClassDefFoundError: com/thoughtworks/xstream/converters/ConversionException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.jmeter.NewDriver.main(NewDriver.java:257)
Caused by: java.lang.ClassNotFoundException: com.thoughtworks.xstream.converters.ConversionException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
JMeter home directory was detected as:
D:\Users\1255592\Desktop\apache-jmeter-3.1\apache-jmeter-3.1
I am using java 1.7
Your installation of JMeter is corrupt as the message here tells you that a class of xstream which is embedded as part of jmeter in lib folder is missing.
com.thoughtworks.xstream.converters.ConversionException
So reinstall your version and ensure you unzip in a folder that you own.

Jar file execution issue?

I am using this command to run my jar file
java -cp otpreq.jar com.otp.req.SendRequest
and its giving error-:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/RequestEntity
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.methods.RequestEntity
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)
... 7 more
Why this error is coming I can't figure out .
I checked the Library and org/apache/commons/httpclient/methods/RequestEntity is a Interface.
Assuming you have the http-client.jar:
java -cp otpreq.jar:http-client.jar com.otp.req.SendRequest
If O.S is windows, replace : by ;
Note: the newest httpclient is not located at apache commons, but at apache http components
You have to include all the supporting jars in class path (command line itself).
Or bind all your supporting jars inside otpreq.jar.
Either one of these will solve this issue.

java .jar file convert to .exe file

I use launch4j to convert jar file to the exe file in Windows XP.
After I build wrapper, I go to test the wrapper.
However, it shows ""Error : A JNI error has occurred ,please check your installation and try again" and "A Java Exception has occured".
Below is the errors:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jdesktop/swingx/JXDatePicker
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.jdesktop.swingx.JXDatePicker
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)
... 7 more
What does the errors say? How should I do?
You need to add a jar that contains the class
JXDatePicker
This is where you can get it from http://www.java2s.com/Code/Jar/s/Downloadswingx094jar.html
Add it in the libraries, and link the path..It must not give this error.

Java programs cannot run after downloading opencsv

I downloaded the opencsv (from http://sourceforge.net/projects/javacsv/files/latest/download) and since then I have been getting this error with all my Java programs
java.lang.NoClassDefFoundError: HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main"
How can I fix this? I realized I didn't need the opencsv anyway...how can I remove it so that my programs can compile and run as usual? I'm using Eclipse Version: 1.4.2.20120213-0813
You can remove a plugin by going to Help->About (or Eclipse->About on a Mac), choosing installations details, selecting the plugin you wish to remove, and choosing 'Uninstall'.

Categories