How to use ROME in Intellij?

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

So far I have 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 some errors when running my code, mainly from the option:

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

How to import a package in Intellij ? I managed to import this added jar into my project structure.

But the following problem: I cannot access org.jdom.Document - although I installed jdom in my project structure. The error I get is this

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

How can i solve this?

+4
source share
2 answers

If you are using Maven or gradle, add the dependency to your configuration file (e.g. pom.xml in Maven) and build / install to load your dependencies. After that, it should work fine. Dependency information is here: http://mvnrepository.com/artifact/rome/rome/0.9

Otherwise, add the jar (downloaded from the link above) manually to your project. Look at the first answer in this question to see how to do it: The correct way to add external jars (lib / *. Jar) to the IntelliJ IDEA project

+3
source

I am the developer of the ROME team. The latest version is ROME 1.5. It can be obtained from the maven central repository: http://search.maven.org/#artifactdetails%7Ccom.rometools%7Crome%7C1.5.1%7Cjar

The id group has changed to com.rometools in version 1.5.0. #

I highly recommend that you use Maven, Gradle, or another build tool that can resolve transitive dependencies, so you don’t have to manually collect all the dependencies.

0
source

All Articles