Jar file error on the web server - java

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.

Related

Apache nifi doesn't start

I've tried several times to run an Apache Nifi server, but it won't work. I'm using windows 8 and installed java version 8.
I get this error message:
'nifi-env.bat' is not recognized as an internal or external command, operable program or batch file.The JAVA_HOME environment variable is not defined correctly.Instead the PATH will be used to find the java executable.
Error Screenshot:
I've tried the solution to the following similar problem, but this did not help:
Nifi commands on windows
I've also tried what is explained in this video, but this did not work either:
How to Install Apache NiFi and run Simple Process
What should I do in order to run the nifi?
There seems to be a Java installation error, which is affecting the nifi-env.bat file. Problem will be solved if you create a virtual environment with java. The following link explains how to create a Java Virtual environment. This will also solve the problem with 'nifi-env.bat' is not recognized as an internal or external command as in that case nifi would only be able to be run within the virtual environment.
Try to troubleshoot the problem by reinstalling java, if the above doesn't work out.
I have pulling my hair off for this, but I discovered the directory which holds nifi, must have not spaces.
My folder's name was "apache nifi" and there I unzipped the download from apache nifi's website, but after one hour I realized the name could be the problem, and actually it was. I just changed folder's name from "apache nifi" to just "nifi" and voilá, it just runs.
Check if JAVA_HOME path is set properly.

How to execute Carrot2 Document Clustering server

I downloaded the Carrot2 Document clustering server build 3.15.0 for Mac. The read me file says:
The DCS requires a Java Runtime Environment (JRE) version 1.7.0 or later. To
run the DCS, execute the 'dcs' script and point your browser at
http://localhost:8080 for further instructions.
Mac OS Sierra doesn't make it easy, but I got 1.8.0_112 installed.
The problem is that I don't know how to execute the 'dcs' script.
There are .cmd, .sh, .war, and .jar files. I wasn't sure which of those to work with. I thought .jar looked promising, so I followed some of this thread and tried this in a terminal window:
java -jar invoker.jar
I cd-ed to the correct directory, but it just says Provide main class, but I'm not sure what or where that is.
Can anybody provide instructions or a link to how to do this?
Use the dcs.sh (on Linux/Mac) and dcs.cmd (on Windows) to start the server. The scripts will set some extra options for the JVM and then start the DCS. In case of any problems, append the -v option to see diagnostic output.

Getting java.lang.NoClassDefFoundError: org/apache/xpath/objects/XObject

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

Issue Running MatlabControl

I have successfully compiled the "Hello World" example found on this link: http://code.google.com/p/matlabcontrol/wiki/Walkthrough.
However, when I try to run it, I get the following exception:
Exception in thread "main" matlabcontrol.MatlabConnectionException:
Could not launch MATLAB. Command: [matlab, -desktop, -r, javaaddpath '/usr/local/MATLAB/R2011a/java/jar/matlabcontrol-4.0.0.jar'; matlabcontrol.MatlabClassLoaderHelper.configureClassLoading(); javarmpath '/usr/local/MATLAB/R2011a/java/jar/matlabcontrol-4.0.0.jar'; matlabcontrol.MatlabConnector.connectFromMatlab('PROXY_RECEIVER_6eb278d0-1401-4b9c-b9e4-80512708f9b7', 2100);].
I have Matlab2011a installed in Ubuntu 11.10.
Could anyone point out where the problem could possibly be?
If you check the compatibility between OS and MATLAB version?
https://code.google.com/p/matlabcontrol/wiki/Compatibility
I suggest that you should update matlabcontrol-4.0.0.jar to latest version matlabcontrol-4.1.0.jar which can be downloaded from website.
Remember to open MATLAB before running the code and check if you have included all related jar files (jmi.jar...etc)to the java build path.
That exception that you posted suggests that you need to add Matlab to your system path. Check online guides on how to do that on Ubuntu.

JAXB generate java class from xsd

JAXB 1.5 installed under C:\Sun\jwsdp-1.5
J2SE 1.4.2 installed under C:\j2sdk1.4.2_08
copied sample.xsd file to C:\Sun\jwsdp-1.5\jaxb\bin
went to C:\Sun\jwsdp-1.5\jaxb\bin and ran xjc.bat -p com.package sample.xsd
got error message: Unrecognized option: -p
Could not create the Java virtual machine.
Please help me out, thanks a lot
This page seems to indicate tha xjc.bat needs Java 1.5+ :
http://forums.sun.com/thread.jspa?threadID=5359378
The last JAXB version that is compatible with java 1.4.2 is JAXB 1.0.6. I've never heard of a version 1.5... Where did you get it?
Edit
This error message is not generated by jaxb but by the JVM. Looks like, the jvm thinks, the '-p' parameter is a jvm parameter. Here's another page where the same error message was generated at a simple java --version call.
And another explanation for the error.
I faced the similar problem and I resolved it using the following approach.
I specified Jdk1.5 as the JDK while installing jwsdp1.5. But the system had jdk1.4 also installed. So I created the following batch file:
set JAVA_HOME=D:\apps\BEA\Weblogic\jdk150_04
set ANT_HOME=H:\Sun\jwsdp-1.5\apache-ant
set JWSDP_HOME=H:\Sun\jwsdp-1.5
set PATH=%JAVA_HOME%\bin;%PATH%;
%JWSDP_HOME%\jaxb\bin\xjc -p package -dtd sample.dtd
This resolved the error. Alternatively we can remove the Jdk1.4 path in the PATH environment variable, in that case, we need to write the batch file.

Categories

Resources