javaintellij-idearome

How to use ROME in Intellij?


How can I set up my project in Intellij to use the ROME library to read a RSS Feed?

So far, I've developed the following:

import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;

import java.net.URL;

public class ReadRSS {

    public static void main(String[] args) {
        String urlString = "http://news.ycombinator.com/"
        boolean ok = false;
        if (args.length==1) {
            try {
                URL feedUrl = new URL(urlString);

                SyndFeedInput input = new SyndFeedInput();
                SyndFeed feed = input.build(new XmlReader(feedUrl));

                System.out.println(feed);

                ok = true;
            }
            catch (Exception ex) {
                ex.printStackTrace();
                System.out.println("ERROR: "+ex.getMessage());
            }
        }

        if (!ok) {
            System.out.println();
            System.out.println("FeedReader reads and prints any RSS/Atom feed type.");
            System.out.println("The first parameter must be the URL of the feed to read.");
            System.out.println();
        }
    }
}

But, I get multiple errors when running my code, mainly of the variant:

.. java:package com.sun.syndication.feed.synd does not exist..

How do I import the package in Intellij? Managed to import this my adding jar in my project structure.

But the next problem is: I can't access org.jdom.Document - though I have installed jdom in my project structure. The error I get is

Error:(16, 38) java: cannot access org.jdom.Document class file for org.jdom.Document not found

How can I resolve this?


Solution

  • If you're using Maven or gradle add the dependency in your configuration file (ex. pom.xml in Maven) and do a build/install to download your dependencies. It should work fine after that. Dependency info is here: http://mvnrepository.com/artifact/rome/rome/0.9

    Otherwise add the jar (downloadable from the link above) manually to your project. Look at the first answer in this question to see how to do this: Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project