I am trying to migrate my application from JRE6 to JRE7 on LINUX machine. I am getting this error java.lang.NoClassDefFoundError: org/apache/xpath/objects/XObject while I was deploying the application.
One of the jar(which would be compiled with some lower JAVA version) calls some function in the class XObject.
Is there any possibility to have version compatibility issue. I have not changed anything in build.xml file and it perfectly runs fine on JRE6.
You have do add the xalan.jar to your classpath.
org/apache/xpath/objects/XObject
above error indicate that there is no such type of class found in your project right?
So you have to need the above jar file of org/apache/xpath/objects/XObject and complie your java class with following command as class path reference. You can download this jar from here http://www.java2s.com/Code/Jar/x/Downloadxalan240jar.htm
javac -cp jar_file_path.jar pachakge/java_file.java
Related
I have a Java Code where I am able to run it on Intellij using custom configuration. The configuration has following attributes :-
module : java 8 (Oracle OpenJDK 1.8.0_321)
classpath : -cp XYZ.main()
main : com.ABC.XYZ.ManageTraffic
CLI arguements : server XYZ.yml
But when I try to run the jar that was build using gradle from terminal , it gives me Error , could not find or load main class com.ABC.XYZ.ManageTraffic
So far I have tried the following things looking at other solutions at Stackoverflow , still getting the same error
java -jar ques.jar
java -jar ques.jar com.ABC.XYZ.ManageTraffic
java -cp /build/libs/ques.jar com.ABC.XYZ.ManageTraffic
Just to cross check , I unzipped the creataed jar and found that com.ABC.XYZ.ManageTraffic class file is available there , still getting error. What could be the issue?
Run it from the IDE, and while it is running, try to get the command used by the IDE from the process list.
not sure what OS you are using but something like this should work on linux/mac:
ps -ef | grep java
After you have the command you can try to understand why its not working for you, or just use that command
Just want to add how I managed to run it. I created a new shaded jar file of the same application. refreshed its dependencies and now it works. I am yet to find out how creating a shaded jar instead of normal jar helped. Right now the only reason I could figure out is there may be version clashes with some dependencies but I wonder how it could throw could not found main class error.
Anyways , then I ran the file with the following command from terminal:
java -jar ./build/libs/ques-shaded.jar server XYZ.yml
I am trying to run a jar file on Linux but it requires another jar file to run. To be specific I have added ojdbc8 separately in Eclipse as I am unable to add it in pom.xml. In Eclipse it works fine but in Linux when I try to run the command
java -cp "/home/eim_master/EirRefresh/lib/ojdbc8.jar" -jar EirRefresh-0.0.1-SNAPSHOT.jar
even after including ojdbc8 jar it still fails throwing
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
I need to run the main class and start the spring boot application
The -cp option is for a directory.
Try java -cp "/home/eim_master/EirRefresh/lib/" -jar EirRefresh-0.0.1-SNAPSHOT.jar
I tried this and it worked for me
java -cp "target/EirRefresh-0.0.1-SNAPSHOT.jar:lib/ojdbc8.jar" org.springframework.boot.loader.JarLauncher
I have a .jar file that works perfectly on my mac, but I need to run it on the web server... So when I use command line to make this file work it gives me this error:
[root#mysite.com dist]$ java -jar PDFparser.jar ffive.pdf
Exception in thread "main" java.lang.NoSuchMethodError: method java.lang.String.getBytes with signature (Ljava.nio.charset.Charset;)[B was not found.
at org.apache.commons.io.IOUtils.write(IOUtils.java:1527)
at org.apache.commons.io.FileUtils.writeStringToFile(FileUtils.java:1929)
at org.apache.commons.io.FileUtils.writeStringToFile(FileUtils.java:1962)
at pdfparser.PDFparser.main(PDFparser.java:171)
I am not the one who created that .jar app but it works just the way I need on my mac... but it need it for the site, so I need it to be working on the web server... Does anyone know what does this error mean and what should I do? I don't know Java language so it would be awesome if you explain to me what should I do like I'm very stupid person...step by step... :)
String.getBytes(Charset c) has only been available since Java 1.6. Most likely, the Java version on your Mac is 1.6+, but your target server is less than 1.6.
You will need to update to at least Java 1.6 on your web server for this method to be available.
Source
This
java.lang.NoSuchMethodError: method java.lang.String.getBytes with signature (Ljava.nio.charset.Charset;)[B was not found.
means that a class in your jar file couldn't find a corresponding method in the Java installation. I suspect your jar file was created with a java version greater/newer than that installed on your web server.
On your working server, type
$ java -version
and do the same on your web server, and compare the version numbers.
There is no issue with your mac or the webserver. The jar was created with a lower version of Java (1.5 or below) while String.getBytes() is only available with java 1.6+.
There is a version mismatch.
I am attempting to install Hibernate3 onto my linux server but I'm having a hard time figuring out what to do to get it to work. I have tried the following:
copy required jars into a folder and called the folder via "java -classpath etc." and got
java -classpath /home/mcmaster/javalibs/* -jar craftbukkit.jar
Error: Could not find or load main class .home.mcmaster.javalibs.dom4j-1.6.1.jar
load the java command while calling only the core hibernate which resulted in normal class not found error
on a whim installed to system java lib location with no affect
used apt-get to install libhibernate3-java with no change
I have attempted to export $CLASSPATH=~/javalibs which has all the required jars
I'm literally pulling my hair out as an intermediate java user trying to learn some more advanced things(to me).
Here's the error I'm getting when trying to call the Session Class:
Caused by: java.lang.ClassNotFoundException: org.hibernate.Session
Looks like you forgot the quotation marks. Try
java -classpath '.:/home/mcmaster/javalibs/*' -jar craftbukkit.jar (as seen on wikipedia).
EDIT: I am guessing that craftbukkit.jar is executable.
I'm trying to send an email using JavaMail API.
I have jdk 1.5 installed in my home directory from self-extracting binary. I'm on Ubintu 9.10
I compile the program using the next command:
~/jdk1.5.0_22/bin/javac -classpath ~/jdk1.5.0_22/jre/lib/javamail-1.4.3/mail.jar:~/jdk1.5.0_22/jre/lib/jaf-1.1.1/activation.jar hw.java
It compiles OK. As you can see I have specified the path to mail.jar and activation.jar
Now I try to run the app using the next command:
~/jdk1.5.0_22/bin/java -classpath ~/jdk1.5.0_22/jre/lib/jaf-1.1.1/activation.jar:~/jdk1.5.0_22/jre/lib/javamail-1.4.3/mail.jar:. HelloWorldApp
I get an exception java.lang.NoClassDefFoundError: javax/mail/Address
Why can it find classes when compiling and cannot do it when running?
How to correctly run my app?
Thanks in advance
That class should come from your mail.jar. I'm not sure your classpath is being parsed properly. The tilde (~) is a shell function and needs expanding before being sent to the Java process. Have you tried removing the ~ and replacing with /home/{whatever} ? I suspect that's the issue.