2010-02-16 48 views
6

我从我的项目中删除罐子(pdfbox,bouncycastle等),并将它们移动到另一个文件夹,但我将它们包括在构建路径后,我得到这个异常...我得到这个异常:未解决的编译问题

在第一行eclipse显示此错误(构造函数PDFParser(InputStream)是指缺少类型InputStream)-altought FileInputStream是从InputStream扩展,我不知道为什么?

FileInputStream in = new FileInputStream(path); 
PDFParser parser = new PDFParser(in); 
PDFTextStripper textStripper = new PDFTextStripper(); 
parser.parse(); 
String text = textStripper.getText(new PDDocument(parser.getDocument())); 

有什么想法吗? **

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problems: 
The constructor PDFParser(InputStream) refers to the missing type InputStream 
The constructor PDFTextStripper() refers to the missing type IOException 
The method parse() from the type PDFParser refers to the missing type IOException 
The method getText(PDDocument) from the type PDFTextStripper refers to the missing type IOException 
The method getDocument() from the type PDFParser refers to the missing type IOException 
The method getDocument() from the type PDFParser refers to the missing type IOException 
The method close() from the type COSDocument refers to the missing type IOException 

**

+0

请注意,Eclipse有一个“增量编译器”,因此一些(大部分)代码可能已经被编译,而另一些则没有。 –

+0

它是一个非常好的理念,试图从头开始编写漏洞项目。谢谢你 – Stephan

回答

9

这只是意味着你的项目尚未编制,但你仍然试图运行它。 Eclipse允许你这样做,当你第一次尝试调用一些没有正确编译的东西时,它只会失败。

看看你的项目中的编译错误,以追查真正的问题。看起来很奇怪,它找不到InputStream:你是否同时从代码中删除了一堆导入语句?

+0

谢谢你的回复。不,我只是将罐子移动到另一个文件夹,并将它们添加到构建路径中......它不会在导入区域显示任何错误 – Stephan

+0

@Stephan:好吧,忽略导入区域,但看看错误视图 - 我敢肯定你会看到一些东西。 –

+0

是的,我已经发布了它:在线PDFParser parser = new PDFParser(in);它显示我这个错误“构造函数PDFParser(InputStream)引用丢失类型InputStream”这是第一个错误 – Stephan

1

您可以在eclipse中使用clean进行项目刷新(Project> Clean> All)。

格尔茨, GHAD

+0

谢谢你的建议,但它没有工作 – Stephan

+0

@Stephan - 你有没有尝试这两个建议? –

+0

是干净所有+刷新 – Stephan

1

A“缺少类型”错误意味着相应的类型没有在构建路径找到。 InputStream将位于JRE类路径容器中。您是否删除了JRE类路径容器,或者它可能指的是错误的位置?

second hit搜索对谷歌

“缺失型” 的InputStream

时也可能会有所帮助。

+0

我想到了这一点,我检查了它的构建路径(JRE系统库JavaSE-1.6) – Stephan

+0

您是否尝试过读取它,就像我链接到的博客所示? – meriton

+0

我重新加载了jre库,但没有成功......无论如何感谢链接 – Stephan

0

Eclipse正试图告诉您所引用的类型在您正在使用的类类型中是“缺少”的。假设你有A,B和C类,其中B引用C作为字段变量;虽然说,在类A中调用B.setC(),但如果C无法通过B到达,则会看到“引用缺少类型”错误。因此,请检查B以查看是否(1)B编译为OK,并且导入C在编译/构建路径中。

相关问题