java.lang.NoClassDefFoundError的:com.itextpdf.text.Document [英] java.lang.NoClassDefFoundError: com.itextpdf.text.Document
问题描述
在 HTTP说明我已经添加了.jar文件到我现有的项目//www.vogella.com/articles/Eclipse/article.html#classpath 。
当我尝试运行模拟器我结束了java.lang.NoClassDefFoundError的:com.itextpdf.text.Document
我的.classpath文件:
<&类路径GT;
< classpathentry样=SRC路径=SRC/>
< classpathentry样=SRC路径=根/>
< classpathentry样=CON路径=com.android.ide.eclipse.adt.ANDROID_FRAMEWORK/>
< classpathentry样=CON路径=com.android.ide.eclipse.adt.LIBRARIES/>
< classpathentry样=LIB路径=LIB / iText的-PDFA-5.3.3-javadoc.jar/>
< classpathentry样=LIB路径=LIB / iText的-PDFA-5.3.3-sources.jar/>
< classpathentry样=LIB路径=LIB / iText的-PDFA-5.3.3.jar/>
< classpathentry样=LIB路径=LIB / iText的-XTRA-5.3.3-javadoc.jar/>
< classpathentry样=LIB路径=LIB / iText的-XTRA-5.3.3-sources.jar/>
< classpathentry样=LIB路径=LIB / iText的-XTRA-5.3.3.jar/>
< classpathentry样=LIB路径=LIB / itextpdf-5.3.3-javadoc.jar/>
< classpathentry样=LIB路径=LIB / itextpdf-5.3.3-sources.jar/>
< classpathentry样=LIB路径=LIB / itextpdf-5.3.3.jar/>
< classpathentry样=输出路径=斌/班/>
< /类路径>
MainActivity.java
包com.example.tmp;进口java.io.FileOutputStream中;进口com.itextpdf.text.Document;
进口com.itextpdf.text.pdf.PdfWriter;进口android.os.Bundle;
进口android.app.Activity;
进口android.view.Menu;公共类MainActivity延伸活动{ @覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main); 字符串FILE =/home/ronline/Desktop/FirstPdf.pdf;
尝试{
文档的文档=新的文件();
PdfWriter.getInstance(文件,新的FileOutputStream(FILE));
document.open();
document.close();
}赶上(例外五){
e.printStackTrace();
} } @覆盖
公共布尔onCreateOptionsMenu(菜单菜单){
。getMenuInflater()膨胀(R.menu.activity_main,菜单);
返回true;
}
}
有关未知的原因,通过月食接口获取罐子Java库不起作用。手动复制/过去到libs文件夹的伎俩。 THX到PARTH多希建议。
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;
}
}
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.
这篇关于java.lang.NoClassDefFoundError的:com.itextpdf.text.Document的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!