3

I'm trying to make use of a jReddit library, which, in turn requires apache HttpComponents and Commons IO libraries.

I downloaded the sources, added them in Itellij Idea through File - Project Structure - Modules - Add Content Root.

All the classes from the libraries that my code makes use of are imported successfully. But the problem appears when compiling - it says that package com.github.jreddit.oauth does not exist and package org.apache.http.impl.client does not exist and that it cannot find symbol of those libraries' classes.

Why does this happen and how to fix it?

7
  • 1
    Why aren't you using maven? Commented Aug 13, 2017 at 21:14
  • @Oleg, I never used it before.. Commented Aug 13, 2017 at 21:17
  • 1
    Possible duplicate of stackoverflow.com/questions/20137020/…. And I agree with @Oleg - cosider using maven or better gradle to build your projects Commented Aug 13, 2017 at 21:28
  • 1
    @IvanPronin Which one is better is extremely debatable. From my personal experience it's much better to use maven. Commented Aug 14, 2017 at 10:43
  • 1
    @Oleg, Hey, I'd take your advice into consideration, it's just I really need a quick solution for now, but I do intend to learn maven later on. Commented Aug 15, 2017 at 19:51

2 Answers 2

1

Don't use Maven or Gradle if you can't even manage adding a JAR to your project manually.

You should acquire those JARs (containing .class byte code files, not .java source), add them a folder in your project named /lib, and add that directory as a JAR source location in your project. They'll be in the CLASSPATH then.

You need to add the /lib folder to an artifact when you run. Be sure you know how to do that as well.

Sign up to request clarification or add additional context in comments.

2 Comments

So I need to first compile all the libraries that I need?
Compile? No, download the JAR, not the sources. It's all compiled for you. Just add to the CLASSPATH as I told you.
1

I ran into this error after upgrading IntelliJ to version 2019.1. These steps fixed it for me:

  1. Click Run from the toolbar
  2. Choose Edit Configurations
  3. Make sure the Scratch file you want to run is selected on the left panel
  4. In Use classpath of module dropdown, select the project module that contains the proper module

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.