Java Importing Packages

Associate
Joined
18 Mar 2007
Posts
291
Hi guys,

I'm trying to get ROME: http://wiki.java.net/bin/view/Javawsxml/Rome working to read an RSS feed but am unsure as to how to import custom packages. The packages you have to download are on that page, but how do i specify them when i come to compile them?

At the moment I have this code:

Code:
package com.sun.syndication.samples;

import java.net.URL;
import java.io.InputStreamReader;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;

/**
 * It Reads and prints any RSS/Atom feed type.
 * <p>
 * @author Alejandro Abdelnur
 *
 */
public class FeedReader {

    public static void main(String[] args) {
        boolean ok = false;
        if (args.length==1) {
            try {
                URL feedUrl = new URL(args[0]);

                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();
        }
    }

}

I get errors on these import statements when doing:

Code:
javac FeedReader.java &

This is when the com folder is in the same location as FeedReader.java.

How do i get it to succesfully import?
 
i keep getting an error saying:

Code:
package com.sun.syndication does not exist

when doing:

Code:
import com.sun.syndication.*;

The com folder is definitely in the same folder as FeedReader.java .

I have taken out the package com.sun.syndication.samples line as well.

Any ideas?
 
Hi mate,

I must be doing something wrong coz when i have it set up like:

explorerry6.jpg


and do:

cmdfh4.jpg


I'm getting that error. Maybe I have interpreted your code wrong and am not meant to just type exactly what you did?

Cheers
 
hmm, have you compiled it? i still can't get it working. where do i put the feed and io folders? when i put them in \sun\syndication it gives me a hell of a lot of errors
 
i think that could well be the problem. will have a little research into JDOM later and also try it on my linux machine. thanks for your help!
 
Back
Top Bottom