简体   繁体   中英

Jar file doesn't work on the web server

I have an Jar file that is working perfectly fine on my Mac using console:

 MacBook-Pro-Pavel:PDFparser pavelpigalev$ java -jar PDFparser.jar
 Usage: java PDFparser <input-pdf> -p1 <password> -c1 -i0 -s1
    -p1 : PDF password
    -c1 : write JSON to console
    -i0 : don't extract images
    -s1 : take page screenshots [WARNING: currently in beta]
 MacBook-Pro-Pavel:PDFparser pavelpigalev$ java -jar PDFparser.jar f5.pdf
 MacBook-Pro-Pavel:PDFparser pavelpigalev$ 

It creates a folder and puts out images that I need in that folder.

But if I use it on the web server (also using console) it gives me this error:

 [root@somesite.com pdfparser]$ ls
ffive.pdf  lib  PDFparser.jar  README.TXT
[root@somesite.com pdfparser]$ java -jar "PDFparser.jar"
Usage: java PDFparser <input-pdf> -p1 <password> -c1 -i0 -s1
    -p1 : PDF password
    -c1 : write JSON to console
    -i0 : don't extract images
    -s1 : take page screenshots [WARNING: currently in beta]
[root@somesite.com pdfparser]$ java -jar "PDFparser.jar" ffive.pdf
Exception in thread "main" java.lang.ClassNotFoundException: javax.vecmath.Vector2d not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:PDFparser.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
   at java.net.URLClassLoader.findClass(libgcj.so.10)
   at java.lang.ClassLoader.loadClass(libgcj.so.10)
   at java.lang.ClassLoader.loadClass(libgcj.so.10)
   at java.lang.reflect.Field.getType(libgcj.so.10)
   at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.excludeField(ReflectiveTypeAdapterFactory.java:56)
   at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:111)
   at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72)
   at com.google.gson.Gson.getAdapter(Gson.java:353)
   at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:52)
   at com.google.gson.Gson.getAdapter(Gson.java:353)
   at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:82)
   at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:81)
   at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:118)
   at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:72)
   at com.google.gson.Gson.getAdapter(Gson.java:353)
   at com.google.gson.Gson.toJson(Gson.java:578)
   at com.google.gson.Gson.toJson(Gson.java:565)
   at com.google.gson.Gson.toJson(Gson.java:520)
   at com.google.gson.Gson.toJson(Gson.java:500)
   at pdfparser.PDFparser.main(PDFparser.java:163)

I didn't make this Jar file, I don't really know much about Java. I work with PHP and I really need this program working well on server. Can someone help me with that?

Place vechmath .jar in your class path

Or - Add your supporting .jar s to the classpath

export CLASSPATH=$CLASSPATH:/path/to/vecmath.jar

Or - Supply at the Runtime

java -cp vecmath-xxx.jar -jar Yourjar.jar

Importance of Classpath

You're not using the same JVM that the one in your macbook. You're using GNU JVM as seen in not found in gnu.gcj.runtime.SystemClassLoader

Try a java -version to confim that and then change your JVM

Try to find vecmath-1.3.1.jar file on you Mac and place it in the same dir as PDFparser.jar is located. Try to run. If no success then try to run as follow:

 java -cp vecmath-1.3.1.jar -jar "PDFparser.jar"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM