java lib connect to another lib error - java

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

Related

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.

how to solve a JNI error has occured in cmd line using edu.mit.jwi

When i run my maven project from eclipse it runs ok. But when i run it from cmd line as a jar file i have the following error:
A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: edu/mit/jwi/IDictionary
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: edu.mit.jwi.IDictionary
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
But i don't use the
IDictionary.class
in my project, instead i use the
Dictionary.class
of jwi library, so i don't understand why i have the above error and what exactly is that.
Please help!!!!

Executing jar file throws class not found error

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

Run multiple jar files from batch file one by one

I've exported my Java projects into a runnable jar file with the libaries combined in another folder. I'm trying to the first one to run, when it finishes the second one starts, etcetera. Right now this is what my batch file looks like:
java -jar "C:\path-to-project1.jar" parameter /wait
java -jar "C:\path-to-project2.jar" parameter /wait
java -jar "C:\path-to-project3.jar" parameter /wait
java -jar "C:\path-to-project4.jar" parameter /wait
java -jar "C:\path-to-project5.jar" parameter /wait
However I'm getting the noclassdeffounderror. The only class I'm using in the projects is the main class, which is called "Main.java". It also says " a jni error has occurred. please check your installation and try again".
Should I also call the .lib files or am I missing something else?
This is what the cmd prompts:
C:\Users\EVE\Desktop>java -jar "C:\Users\EVE\Google Drive\Bots\LIVE BOTS\Builds\
Amsterdam-3-172-Heiniken music hall.jar" main parameter /wait
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/N
oSuchElementException
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.openqa.selenium.NoSuchElementEx
ception
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
C:\Users\EVE\Desktop>java -jar "C:\Users\EVE\Google Drive\Bots\LIVE BOTS\Builds\
Amsterdam-3-293-Roode Bioscoop.jar" main parameter /wait
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/N
oSuchElementException
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.openqa.selenium.NoSuchElementEx
ception
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
C:\Users\EVE\Desktop>java -jar "C:\Users\EVE\Google Drive\Bots\LIVE BOTS\Builds\
Amsterdam-4-223-Krakeling.jar" main parameter /wait
LOOP EC=2 EH=1 -----------------------------------------------------------------
--------------------------------
While 1 ------------------------------------------
Exception in thread "main" java.lang.NoClassDefFoundError: Functions
at Main.main(Main.java:250)
Caused by: java.lang.ClassNotFoundException: Functions
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)
... 1 more
I don't know whethere there are more bugs in the code but one is the location of /wait. Try start /wait java -jar "C:\path-to-project1.jar" parameter instead.

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.

Categories