java.lang.NoClassDefFoundError: com.itextpdf.text.Document

主宰稳场 提交于 2019-12-09 18:47:57

问题


I have added the .jar files into my existing project as described in http://www.vogella.com/articles/Eclipse/article.html#classpath .

When I try to run the emulator I end up with “java.lang.NoClassDefFoundError: com.itextpdf.text.Document”

My .classpath file :

<classpath>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
        <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
        <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
        <classpathentry kind="lib" path="lib/itext-pdfa-5.3.3-javadoc.jar"/>
        <classpathentry kind="lib" path="lib/itext-pdfa-5.3.3-sources.jar"/>
        <classpathentry kind="lib" path="lib/itext-pdfa-5.3.3.jar"/>
        <classpathentry kind="lib" path="lib/itext-xtra-5.3.3-javadoc.jar"/>
        <classpathentry kind="lib" path="lib/itext-xtra-5.3.3-sources.jar"/>
        <classpathentry kind="lib" path="lib/itext-xtra-5.3.3.jar"/>
        <classpathentry kind="lib" path="lib/itextpdf-5.3.3-javadoc.jar"/>
        <classpathentry kind="lib" path="lib/itextpdf-5.3.3-sources.jar"/>
        <classpathentry kind="lib" path="lib/itextpdf-5.3.3.jar"/>
        <classpathentry kind="output" path="bin/classes"/>
</classpath>

MainActivity.java

package com.example.tmp;

import java.io.FileOutputStream;

import com.itextpdf.text.Document;
import com.itextpdf.text.pdf.PdfWriter;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

          String FILE = "/home/ronline/Desktop/FirstPdf.pdf";
        try {
            Document document=new Document();
              PdfWriter.getInstance(document, new FileOutputStream(FILE));
              document.open();
              document.close();
            } catch (Exception e) {
              e.printStackTrace();
            }

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}

回答1:


For unknown reason getting the jars to Java Library through eclipse interfaces doesn't work. Manual copy / past into libs folder does the trick. Thx to Parth Doshi suggestion.




回答2:


You should download jar from Here and then try.



来源:https://stackoverflow.com/questions/12768395/java-lang-noclassdeffounderror-com-itextpdf-text-document

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!