Importing Jar files for JReddit giving error

96 Views Asked by At

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.

1

There are 1 best solutions below

2
On

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