2014-03-31 366 views
0

我正在嘗試使用FTPClient讀取文件名。我使用了commons-net-3.3.jar和commons-io-2.4.jar。但在執行時,我得到以下例外,無法解析導入org.apache.oro

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
The import org.apache.oro cannot be resolved 
The import org.apache.oro cannot be resolved 
The import org.apache.oro cannot be resolved 
The import org.apache.oro cannot be resolved 
The import org.apache.oro cannot be resolved 
The import org.apache.oro cannot be resolved 
Pattern cannot be resolved to a type 
MatchResult cannot be resolved to a type 
PatternMatcher cannot be resolved to a type 
_matcher_ cannot be resolved 
Perl5Matcher cannot be resolved to a type 
pattern cannot be resolved 
Perl5Compiler cannot be resolved to a type 
MalformedPatternException cannot be resolved to a type 
result cannot be resolved or is not a field 
_matcher_ cannot be resolved 
pattern cannot be resolved or is not a field 
result cannot be resolved or is not a field 
_matcher_ cannot be resolved 
result cannot be resolved or is not a field 
result cannot be resolved or is not a field 
result cannot be resolved or is not a field 
result cannot be resolved or is not a field 
result cannot be resolved or is not a field 
result cannot be resolved or is not a field 
result cannot be resolved or is not a field 



at org.apache.commons.net.ftp.parser.RegexFTPFileEntryParserImpl.<init>(RegexFTPFileEntryParserImpl.java:19) 
at org.apache.commons.net.ftp.parser.ConfigurableFTPFileEntryParserImpl.<init>(ConfigurableFTPFileEntryParserImpl.java:57) 
at org.apache.commons.net.ftp.parser.UnixFTPEntryParser.<init>(UnixFTPEntryParser.java:136) 
at org.apache.commons.net.ftp.parser.UnixFTPEntryParser.<init>(UnixFTPEntryParser.java:119) 
at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createUnixFTPEntryParser(DefaultFTPFileEntryParserFactory.java:169) 
at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(DefaultFTPFileEntryParserFactory.java:94) 
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2359) 
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2142) 
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2188) 
at com.school.util.GetFileList.main(GetFileList.java:32) 
+1

你如何將jar作爲外部庫包含在項目中? – Jason

+0

你從哪裏得到這些JAR文件?我無法相信你會從Apache獲得他們的編譯問題。 – Thilo

回答

2

看起來你有一箇舊版本的commons-net,它取決於你的classpath中的Jakarta ORO。 Commons-net過去依賴於ORO,直到版本1.4.1
如果您使用的是Maven/Gradle/Ivy,請確保您沒有將此版本作爲傳遞依賴項或其他庫。
捨棄這個舊版本的commons-net應該可以解決問題。

+0

我正在使用ANT構建... – Souvikcs48

+0

因此,請確保Ant正在使用commons-net的正確版本。如果.jar名稱不包含版本,則可以檢查其META-INF/MANIFEST.MF文件 –

+0

中指定的文件,感謝它使用了正確版本的commons-net。 – Souvikcs48

相關問題