0

I get Errors when trying to import the jar files needed for Jreddit to function.

On jreddit's github page it says ...

Dependencies

JSON-simple

Apache HttpComponents

Apache Commons IO

After going to the Maven repository website I download the jar files from the following links ..

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

and importing them to my intellij project I simply

⌘ + ; on Mac OS X → Module → Dependencies → Add... → Project Library → Attach Jar

I get the following errors... Error messages when importing jar files into the my java project

Error message is : Cannot resolve symbol.

Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69
stringRay2014
  • 636
  • 1
  • 11
  • 29
  • It looks like jars doesn't contain this class or you add it for wrong module. Why don't create maven project and add all this dependencies in pom.xml? – Vartlok Apr 06 '15 at 09:43
  • Ive never done one before , any tutorials you recommend? – stringRay2014 Apr 06 '15 at 09:46
  • 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 Apr 06 '15 at 09:48

1 Answers1

3

I'm the current mantainer for jReddit.

First of all, I think you are using an old version of jReddit. From the looks of it you are using 1.0.0 which is the first version. Current version is 1.0.2. Try downloading the jar from here.

Secondly, my recommendation is to include the dependency using maven rather through importing the jar manually.

I've created for you a small pom.xml how to create a simple maven project:

<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>

Try to add your source code in src/main/java

After you finish, run from the command line mvn clean install (keep in mind you need maven installed locally, although AFAIK intellij comes with an embedded maven).

For more about maven, check out this guy

Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69
  • Hey , Thank you for the answer , Im running into a little problem , after running mvn clean install , it downloads the packages fine , but then when i run the program i get the error Error:java: directory not found: /Users/"myname"/Documents/workspace/jredditTesting/target/generated-sources/annotations – stringRay2014 Apr 06 '15 at 15:16
  • after changing from intellij to eclipse i got it to work , now I'm wondering how can I retrieve top 10 comments for for a submission of the world news subreddit? – stringRay2014 Apr 07 '15 at 13:09