Free Support Forum - aspose.com

Problem of Aspose.Pdf.Kit(JAVA) in Linux Platfrom

My code work properly in Window platform, but after I port my code in Linux, I got the follow problem:
Exception in thread "main" java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
at com.aspose.pdf.kit.nw.a(Unknown Source)
at com.aspose.pdf.kit.ga.a(Unknown Source)
at com.aspose.pdf.kit.d6.a(Unknown Source)
at com.aspose.pdf.kit.d6.a(Unknown Source)
at com.aspose.pdf.kit.d6.a(Unknown Source)
at com.aspose.pdf.kit.f9.char(Unknown Source)
at com.aspose.pdf.kit.PdfViewer.decodePage(Unknown Source)
at com.aspose.pdf.kit.PdfExtractor.extractTextInRectangle(Unknown Source)
at splitPdfByStaffId.main(splitPdfByStaffId.java:138)
is the Aspose.Pdf.Kit(JAVA) not supoort in the Linux platform.

Dear hkbu,

Thanks for considering Aspose.pdf.kit for Java!

Generally speaking, our product is implemented by pure Java code. That is to say, it can be employed in any environment hosting Java VM. As to your problem, it seems some classes are not found. Would you be so kind to paste your code about Kit? We will solve it ASAP.

Best regards.

Thanks for considering Aspose.

Our component for Java version can be capable under any platform embedded Java Virtual Machine.

The GraphicsEnvironment class describes the collection of GraphicsDevice objects and Font objects available to a Java(tm) application on a particular platform. It seems some objects are missed during initializing, so plz make sure all required libs are available.

thx for you quick reply.

part of my codes are as below :

x = 10;
y =10;
w =70;
h = 20;
java.awt.Rectangle rec = new java.awt.Rectangle(x, y, w, h);
for (int i=1; i<=pageNo; i++) {
pdfextractor.bindPdf(inFile);

pdfextractor.setStartPage(i);
pdfextractor.setEndPage(i);
pdfextractor.extractTextInRectangle(rec, ExtractTextMode.PureTextWithWidth);
ByteArrayOutputStream out = new ByteArrayOutputStream();
pdfextractor.getAllRectangleText(out);

.

.

.

}

next

if seems that the errors are come from "pdfextractor.extractTextInRectangle(rec, ExtractTextMode.PureTextWithWidth)", the rec object cannot be passed into pdfextractor.extractTextInRectangle.

This part of my code is quite similar to the example code in ExtractTextInRectangle.java. You may try this example code in the linux platform to see whether the same errors exist.

My code work fine in Window Enviornment but fail in linux platform. My jdk in linux is 1.4.2_11.

Thanks for considering Aspose.

Thank you for sharing codes. We will find out reasons which bring out such errors and give an answer soon.

Dear hkbu,

Thanks for your kindness. We tested your code in Red Hat Linux with JDK 1.4.1, but nothing turned out wrong. It seems that it is not a matter of JDK. If you still have troubles, please upload your PDF document whenever possible. We will test again and tell you the result.

Best regards.

lukeyoyo wrote:

Dear hkbu,

Thanks for your kindness. We tested your code in Red Hat Linux with JDK 1.4.1, but nothing turned out wrong. It seems that it is not a matter of JDK. If you still have troubles, please upload your PDF document whenever possible. We will test again and tell you the result.

Best regards.

I've tried simply use the sample code ExtractTextInRectangle.java (use the pdf file containing in the example/resources) in linux enviornment, but I still got the same error. So I don't think the errors are caused by my coding and my pdf file.

Kevin Zuo wrote:

Thanks for considering Aspose.

Our component for Java version can be capable under any platform embedded Java Virtual Machine.

The GraphicsEnvironment class describes the collection of GraphicsDevice objects and Font objects available to a Java(tm) application on a particular platform. It seems some objects are missed during initializing, so plz make sure all required libs are available.

I don't think we have missed to include some lib , as we can successfully compile the codes.

You words sound good, but according to lukeyoyo's explaination, he can not reproduce the same error with the latest version of Aspose.Pdf.Kit for Java. So my advice is:

  1. Could u run your test codes with the attached pdf file? This will do a little help to judge if the problem is not caused by a specified pdf document.
  2. Could u attach your pdf document or mail to kevin.zuo@aspose.com ? We wanna do test your pdf file to locate reasons.

Thanks for your cooperations.

thx for all of your help.

finally I got the solution, use the " java -Djava.awt.headless=true " to run the java program.

please see the following link for reference :

http://java.sun.com/j2se/1.4.2/docs/guide/awt/AWTChanges.html#headless

Thank you for sharing your experience. It will be great helpful to others.