2015-04-06 69 views
0

嘗試導入Jreddit功能所需的jar文件時出現錯誤。導入JReddit的Jar文件給出錯誤

在jreddit的GitHub的頁面,它說...

Dependencies

JSON-simple

Apache HttpComponents

Apache Commons IO

將Maven倉庫網站,我從下面的鏈接下載JAR文件後..

http://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple

http://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient

http://mvnrepository.com/artifact/commons-io/commons-io

,並將它們導入到我的IntelliJ項目,我只是

⌘+;在Mac OS X→模塊→依賴性→添加→...項目庫→安裝JAR

我收到以下錯誤...... Error messages when importing jar files into the my java project

錯誤消息是:無法解析符號。

+0

它看起來像罐子不包含這個類或添加它錯誤的模塊。 爲什麼不創建maven項目並在pom.xml中添加所有這些依賴關係? – Vartlok 2015-04-06 09:43:39

+0

我從來沒有做過一個之前,你建議的任何教程? – stringRay2014 2015-04-06 09:46:33

+0

Maven: http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html http://tutorials.jenkov.com/maven/maven-tutorial.html IDEA maven : https://www.jetbrains.com/idea/help/maven-projects-tool-window。html – Vartlok 2015-04-06 09:48:51

回答

3

我爲jReddit當前mantainer。

首先,我想你使用的是舊版本jReddit的。從外觀上看,您使用的是第一個版本1.0.0。當前版本是1.0.2。嘗試從here下載罐子。

其次,我的建議是包括相當通過手動導入罐子使用maven的依賴。

我已經爲你創建了一個小的pom.xml如何創建一個簡單的Maven項目:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 

<groupId>com.yourcompany.test</groupId> 
<artifactId>jreddit-testing</artifactId> 
<version>1.0-SNAPSHOT</version> 
<packaging>jar</packaging> 

<name>jreddit-testing</name> 
<url>http://maven.apache.org</url> 

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>com.github.jreddit</groupId> 
     <artifactId>jreddit</artifactId> 
     <version>1.0.2</version> 
    </dependency> 

    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
</dependencies> 

嘗試添加源代碼src/main/java

完成後,從命令行mvn clean install運行(請記住,您需要在本地安裝maven,儘管AFAIK intellij帶有嵌入式maven)。

欲瞭解更多有關行家,看看this guy

+0

嘿,謝謝你的回答,我遇到了一個小問題,運行mvn clean install後,它下載的包很好,但是當我運行程序時出現錯誤 Error:java:d​​irectory not found:/用戶/「myname」/文件/工作區/ jreddit測試/目標/生成源/註釋 – stringRay2014 2015-04-06 15:16:52

+0

從intellij更改爲eclipse後,我得到它的工作,現在我想知道如何檢索前10條評論提交的世界新聞subreddit? – stringRay2014 2015-04-07 13:09:40