I have just installed Java1.8.0_112, both jdk and jre 64bit on my Windows 7 machine.
I am attempting to run one of my programs via a .bat file and am getting the following error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/use
rmodel/Workbook
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.poi.ss.usermodel.Workbook
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
I have uninstalled and reinstalled the jre and I have restarted my machine. I have made sure I am pointing to all the libraries needed.
What really baffles me is that this error is showing about the POI workbook, but I have all the apache libraries I need and their appropriate dependencies so I'm not sure why this is an issue. Like I said, runs like a charm in Netbeans on the jdk, but completely implodes when I run it on my desktop via .bat
The program runs just fine in the Netbeans8 environment, which is using the jdk of 1.8.0_112 and the JDK8 binary.
My .bat file is as follows, I've added line breaks for readability:
C:\jre1.8.0_112\bin\java -cp
"T:\Netbeans Projects\MatchReport\build\classes;
S:\ADSJava\Jars\lib\poi-3.15.jar;
S:\ADSJava\Jars\lib\poi-ooxml-3.15.jar;
S:\ADSJava\Jars\lib\poi-ooxml-schemas-3.15.jar;
C:\Users\Jessica\Desktop\lib\xmlbeans-2.6.0.jar;
S:\ADSJava\Jars\lib\dom4j-1.6.1.jar;
S:\ADSJava\Jars\lib\commons-io-2.5.jar;
S:\ADSJava\Jars\lib\junit-4.12.jar;
S:\ADSJava\Jars\lib\commons-codes-1.10.jar;
S:\ADSJava\Jars\lib\commons-collections4-4.1.jar;
C:\Users\Jessica\Desktop\lib\DataServer.jar;
C:\Users\Jessica\Desktop\lib\ucanaccess-3.0.4.jar;
C:\Users\Jessica\Desktop\lib\jackcess-2.1.3.jar;
C:\Users\Jessica\Desktop\lib\xbeans.jar;
C:\Users\Jessica\Desktop\lib\commons-logging-1.0.4.jar;
C:\Users\Jessica\Desktop\lib\hsqldb.jar;
C:\Users\Jessica\Desktop\lib\commons-lang-2.4.jar"
ads.ADSMatchReport2
"Toyota Of Turnersville Control.txt" 2>&1> MatchReportResults.txt
Any help or guidance would be greatly appreciated, thank you!
Found the solution. The .bat file did not like me having libraries on mixed drives. Moving all the libraries to either my C: or the network S: drive solved the issue.
For whatever reason Netbeans was able to handle libraries in multiple locations but the .bat file does not.
Related
I am trying to run a java based java profiler to find out what uses up resources on my java application on my dedicated machine. The profiler I am trying to use is called warmroast.
I get the following error from running.
java -jar warmroast.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException
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.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException
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
I think this error is caused by running the file with jre instead of jdk.
I have installed java-1.7.0-openjdk-1.7.0.55-2.4.7.1.el6_5.x86 as a yum package.
[root# ~]# java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
I think to fix this problem, I will need to run the jar file using jdk. Is there some kind of a jdk path to the jdk bin file? If so, what is it in centos? I've googled for a while and came up with dozens of wrong paths. I feel stupid because I think jre is a part of jdk and jdk is only using for compiling stuff and I don't think you can run files with jdk...
...
...
The class that could not be found is in tools.jar in your JDK. This library is usually not automatically on the class path, even if you use JDK instead of JRE.
According to the documentation, on Linux warmroast should be started as follows (replace PATH_TO_JDK with the path to your JDK):
java -Djava.library.path=PATH_TO_JDK/jre/bin -cp PATH_TO_JDK/lib/tools.jar:warmroast-1.0.0-SNAPSHOT.jar com.sk89q.warmroast.WarmRoast --thread "Server thread"
Here, tools.jar is manually added to the classpath.
I have made a application to grab video from a webcam and detect motion using OpenCV and JavaCV. I am trying to export as an executable jar using eclipse. The program runs fine in eclipse as does the exe jar on the computer I coded the program on.
What I am trying to accomplish is to make the exe Jar run on computers that don't have OpenCV installed. Basically what I would consider a portable application. When I run the exe jar on a different computer that has nothing installed other than the JRE I get unsatisfied link errors seen below.
Exception in thread "Video Thread" java.lang.UnsatisfiedLinkError: C:\Users\JohnD\AppData\Local\Temp\javacpp91062429652918\jniopencv_core.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(Unknown Source)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:566)
at com.googlecode.javacpp.Loader.load(Loader.java:489)
at com.googlecode.javacpp.Loader.load(Loader.java:431)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:136)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:453)
at com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:453)
at com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
at com.googlecode.javacv.OpenCVFrameGrabber.start(OpenCVFrameGrabber.java:174)
at VideoPanel.run(VideoPanel.java:163)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: no opencv_core244 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
at com.googlecode.javacpp.Loader.load(Loader.java:481)
... 13 more
I have looked for a solution to what I am doing wrong. Most of the topics I have come across with unsatisfied link errors like the ones I am receiving have been trying to get it to run the first time through within there IDE, which is not the case here. I would think my dependencies are correct in the libraries in the build path since I can get it to run perfectly when I am on the computer that has everything installed but I still believe I am doing something wrong with the build.
Again I am trying to make it so the Jar can run on computers where OpenCV/JavaCV is not installed. Any help would be greatly appreciated.
If opencv is not installed in the target machine, than you need to deliver the necessary opencv's dll file and set the corresponding library path, opencv is a precondition of javacv
for example:
jar yourapp.jar -Djava.library.path="/path/to/OpenCV/library"
also check this answer
Well, I exported my application into JAR with eclipse, but now whenever I try running it I get the: "A Java Exception has occurred". When I try to run it through command line it says:
C:\Users\Arturas>java -jar D:\Dropbox\EclipseWorkspace\Exports\Dantracio_skaiciu
oklis3.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widge
ts/Composite
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: org.eclipse.swt.widgets.Composite
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
C:\Users\Arturas>
Any solutions to this? I just hate java for this... It never works on desktops when you want it to... sorry I'm really stressed out from this, I'm overreacting...
Any ideas what could cause this? I doesn't work on other computers as well. Right now it's using Java 1.7. And the application runs perfectly on Eclipse.
You need to get your dependencies. Looks like you are depending on swt, which is not part of the core java language. You'll need to get all the third party jars that you depend on and include them in your classpath. It runs perfectly on eclipse because eclipse takes care of setting up the classpath for you.
You can set the classpath in your manifest file as described in the documentation, or you could include a script to start your application that will use the -cp command when running the jar, or you can use something that will package everything into one monster jar like the solutions to this question.
I m trying to compile an open source software . The build works fine and results into a jar file "five-server.jar". When I try to run this file from cmd , I get these errors.
C:\Users\vickey\code\five-server\dist\main>java -jar five-server.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/SWTError
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.SWTError
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)
Could not find the main class: org.devtcg.five.Main. Program will exit.
any suggestion what is wrong?
The SWT Jar files are platform dependent.
See http://www.jarfinder.com/index.php/java/info/org.eclipse.swt.SWTError
e.g. on Windows a suitable jar would be:
org.eclipse.swt.win32.win32.x86_3.1.0.jar
or on Mac OS X:
swt-macosx-3.0m7.jar
and so on.
You might run into call kinds of followup problems if you add this dependency e.g. whether you are
using 32bit or 64bit libraries.
It is too bad that these kind of dependency problems show up more often than not these days :-(
You have to set the classpath so that it includes at least the class org.eclipse.swt.SWTError
or the jar containing it:
java -classpath path/to/jar/containing/org.eclipse.swt.SWTError -jar five-server.jar
You should also set the Main-class attribute in the manifest file in the five-server.jar
Following the #Wolfgang Fahl answer, you might download the references here:
Standard Widget Toolkit » 4.3 x86
Maven reference:
https://mvnrepository.com/artifact/org.eclipse.swt.org.eclipse.swt.win32.win32.x86.4.3.swt/org.eclipse.swt.win32.win32.x86/4.3
Jar file:
http://central.maven.org/maven2/org/eclipse/swt/org/eclipse/swt/win32/win32/x86_64/4/3/swt/org.eclipse.swt.win32.win32.x86_64/4.3/org.eclipse.swt.win32.win32.x86_64-4.3.jar
Standard Widget Toolkit » 4.3 x64
Maven reference: https://mvnrepository.com/artifact/org.eclipse.swt.org.eclipse.swt.win32.win32.x86_64.4.3.swt/org.eclipse.swt.win32.win32.x86_64/4.3
Jar file:
http://central.maven.org/maven2/org/eclipse/swt/org/eclipse/swt/win32/win32/x86_64/4/3/swt/org.eclipse.swt.win32.win32.x86_64/4.3/org.eclipse.swt.win32.win32.x86_64-4.3.jar
I downloaded luke-1.0.1.jar (Luke 1.0.1 binary without any dependencies) from http://code.google.com/p/luke/downloads/list.
And I have WinXP, with latest Java 6 downloaded from Oracle/Sun web site.
I run the command line: "java -jar luke-1.0.1.jar" and try to launch Luke, but I got following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.Analyzer
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)
Could not find the main class: org.getopt.luke.Luke. Program will exit.
Any clue, what shall I do? I totally have no knowledge of Java.
Thanks
Hardy
So Java complains that it cant find a dependency. Which is little surprise since you downloaded a binary without dependencies.
Download the binary with all the dependencies (try the "featured" one) and you should be good.
Use luke-all.jar instead,
http://code.google.com/p/luke/downloads/detail?name=lukeall-1.0.1.jar&can=2&q=
Luke is a tool for examining lucene indices. You need to combine it with Lucene. You can either download Lucene and add appropriare JAR files to the classpath, or download a fatter Luke binary that includes Lucene.