Reading RSS feeds in java/rome: cannot access org.jdom.Document

nasir picture nasir · Apr 22, 2012 · Viewed 13.5k times · Source

I am trying to read RSS feed in java I am using ROME to read the feed, but getting an error cannot access org.jdom.Document class file for org.jdom.Document not found SyndFeed feed = new SyndFeedInput().build(reader); 1 error

I have added the jdom to the lib but still am getting the error. kindly guide me how to solve it. my code is as follows

import java.net.URL;
import java.util.Iterator;

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

public class Reader {

  public static void main(String[] args) throws Exception {

    URL url  = new URL("http://viralpatel.net/blogs/feed");
    XmlReader reader = null;

    try {
      reader = new XmlReader(url);
      SyndFeed feed = new SyndFeedInput().build(reader);
      System.out.println("Feed Title: "+ feed.getAuthor());

      for (Iterator i = feed.getEntries().iterator(); i.hasNext();) {
        SyndEntry entry = (SyndEntry) i.next();
        System.out.println(entry.getTitle());
      }
    } finally {
      if (reader != null)
        reader.close();
    }
  }
}

Answer

ZeroOne picture ZeroOne · Apr 22, 2012

Which version of JDOM did you use? It seems to me that ROME doesn't work with the newest version, 2.0.0, but requires the older version 1. Download the JDOM jar from here.