简体   繁体   English

Jar文件在Web服务器上不起作用

[英]Jar file doesn't work on the web server

I have an Jar file that is working perfectly fine on my Mac using console: 我有一个Jar文件,可以使用控制台在Mac上正常运行:

 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: 但是,如果我在Web服务器(也使用控制台)上使用它,则会出现此错误:

 [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. 我没有制作这个Jar文件,我对Java不太了解。 I work with PHP and I really need this program working well on server. 我使用PHP,因此我确实需要此程序在服务器上运行良好。 Can someone help me with that? 有人可以帮我吗?

Place vechmath .jar in your class path 将vechmath .jar放在您的课​​程路径中

Or - Add your supporting .jar s to the classpath 或者-将支持的.jar添加到类路径中

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. 您所使用的JVM与Macbook中使用的JVM不同。 You're using GNU JVM as seen in not found in gnu.gcj.runtime.SystemClassLoader 您正在使用GNU JVM,如not found in gnu.gcj.runtime.SystemClassLoader

Try a java -version to confim that and then change your JVM 尝试使用java -version确认它,然后更改您的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. 尝试在Mac上找到vecmath-1.3.1.jar文件,并将其放在与PDFparser.jar相同的目录中。 Try to run. 尝试运行。 If no success then try to run as follow: 如果没有成功,请尝试按以下方式运行:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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