OT:News readers..so many to choose from

Discussion in 'Java' started by Print Dude, Jan 27, 2007.

  1. Print Dude

    Print Dude Guest

    Well I've abandoned google groups for the time being and have switched
    over to PAN on Linux and Gravity on Windows. What I am wondering is,
    how hard would it be to write a news reader client in Java? I know it's
    way beyond me, but there must be people reading this ng who have had
    some degree of sucess at it. What was the process you went through to
    design and build the program? How much practical experience would one
    need to be able to sucessfully code such a program? If you know that
    you need say, a class that will send a request to a news server, how do
    you go about finding it in the API documentation? And if you don't find
    one, do you write your own or simply extend one that is already there,
    and is close to what you need? I have a book on OO Design coming, but
    it would be interesting to know what others think. I know this is
    pseudo-off topic, which is why I put the OT in the subject line. This
    is my first post using Gravity so it may not work, but if it does, I
    hope we can have a good discussion about this topic, if it hasn't
    already been hash(tabled) before.

    Cheers
     
    Print Dude, Jan 27, 2007
    #1
    1. Advertising

  2. Print Dude

    Daniel Pitts Guest

    On Jan 26, 6:47 pm, Print Dude <> wrote:
    > Well I've abandoned google groups for the time being and have switched
    > over to PAN on Linux and Gravity on Windows. What I am wondering is,
    > how hard would it be to write a news reader client in Java? I know it's
    > way beyond me, but there must be people reading this ng who have had
    > some degree of sucess at it. What was the process you went through to
    > design and build the program? How much practical experience would one
    > need to be able to sucessfully code such a program? If you know that
    > you need say, a class that will send a request to a news server, how do
    > you go about finding it in the API documentation? And if you don't find
    > one, do you write your own or simply extend one that is already there,
    > and is close to what you need? I have a book on OO Design coming, but
    > it would be interesting to know what others think. I know this is
    > pseudo-off topic, which is why I put the OT in the subject line. This
    > is my first post using Gravity so it may not work, but if it does, I
    > hope we can have a good discussion about this topic, if it hasn't
    > already been hash(tabled) before.
    >
    > Cheers

    Actually, writing a simple newsreader probably wouldn't be too hard,
    the NNTP protocol is well documented, and socket programming is "too
    easy" in Java.

    Out of curiousity, did you abandon Google because of their new look and
    feel?
    I don't like it myself, but I haven't bothered finding an alternative
    yet.
     
    Daniel Pitts, Jan 27, 2007
    #2
    1. Advertising

  3. On Jan 27, 4:36 pm, "Daniel Pitts" <>
    wrote:
    > On Jan 26, 6:47 pm, Print Dude <> wrote:
    >
    > > Well I've abandoned google groups for the time being ..

    ....
    > Out of curiousity, did you abandon Google because of their new look and
    > feel?
    > I don't like it myself, but I haven't bothered finding an alternative
    > yet.- Hide quoted text -- Show quoted text -


    It is pissing me off how it ..
    1) reformats text.
    A good e.g. is the addition of
    '- Hide quoted text -- Show quoted text -'
    above. I would usually trim/reformat it.
    2) Does not allow me to change thread titles
    (though arguably, that is a good thing, in general)
    3) Will not 'auto-text'/'bring up' past x-posts I
    have made, when typing in the 'Newsgroups'
    box (instead it sems to produce email
    addresses from my gmail account!)

    ...anyway, back to the ..already off-topic
    thread.

    Andrew T.
     
    Andrew Thompson, Jan 27, 2007
    #3
  4. Print Dude

    Daniel Pitts Guest

    On Jan 26, 9:36 pm, "Daniel Pitts" <> wrote:
    > On Jan 26, 6:47 pm, Print Dude <> wrote:
    >
    > > Well I've abandoned google groups for the time being and have switched
    > > over to PAN on Linux and Gravity on Windows. What I am wondering is,
    > > how hard would it be to write a news reader client in Java? I know it's
    > > way beyond me, but there must be people reading this ng who have had
    > > some degree of sucess at it. What was the process you went through to
    > > design and build the program? How much practical experience would one
    > > need to be able to sucessfully code such a program? If you know that
    > > you need say, a class that will send a request to a news server, how do
    > > you go about finding it in the API documentation? And if you don't find
    > > one, do you write your own or simply extend one that is already there,
    > > and is close to what you need? I have a book on OO Design coming, but
    > > it would be interesting to know what others think. I know this is
    > > pseudo-off topic, which is why I put the OT in the subject line. This
    > > is my first post using Gravity so it may not work, but if it does, I
    > > hope we can have a good discussion about this topic, if it hasn't
    > > already been hash(tabled) before.

    >
    > > Cheers

    > Actually, writing a simple newsreader probably wouldn't be too hard,
    > the NNTP protocol is well documented, and socket programming is "too
    > easy" in Java.


    To follow up. in the last 30 minuts, I wrote a simple Swing application
    that will download a list of newsgroups from my local provider, and
    display them in a JTree.

    It wouldn't be hard to "extend" this to download messages for a
    particular group.
    My only references were: <http://tools.ietf.org/html/rfc977> and of
    course the JDK javadoc.

    Less than 100 lines of code too:
    <sscce file="GroupSSCCE.java" javac="GroupSSCCE.java" run="java
    GroupSSCCE">
    import javax.swing.*;
    import javax.swing.tree.DefaultTreeModel;
    import java.awt.*;
    import java.io.*;
    import java.util.*;

    class GroupSSCCE {
    static final String MESSAGE = "Please enter your nntp server
    address";

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

    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);
    String host = getHost();

    final GroupNode root = new GroupNode(host);

    final DefaultTreeModel model = new DefaultTreeModel(root);
    final JLabel countLabel = new JLabel("");
    initMainFrame(model, countLabel, host);

    java.net.Socket socket = new java.net.Socket(host, 119);

    BufferedReader in = getIn(socket);
    PrintWriter out = getOut(socket);

    System.out.println(in.readLine());
    out.println("list");
    out.flush();
    System.out.println(in.readLine());

    long count = 0;
    for (String line = in.readLine();
    line.trim().length() > 1;
    line = in.readLine()) {
    addGroup(root,new StringTokenizer(getGroupName(line),
    "."),model);
    countLabel.setText("Groups: " + ++count);
    }
    System.out.println("Done!");
    }

    static void addGroup(GroupNode node,
    StringTokenizer tokenizer, DefaultTreeModel model)
    {
    while (tokenizer.hasMoreTokens()) {
    node = node.walkTo(model, tokenizer.nextToken());
    }
    }

    static String getHost() {
    return JOptionPane.showInputDialog(MESSAGE, "news.astound.net");
    }

    static PrintWriter getOut(java.net.Socket socket) throws Throwable {
    return new PrintWriter(socket.getOutputStream());
    }

    static BufferedReader getIn(java.net.Socket socket) throws Throwable
    {
    return new BufferedReader(
    new InputStreamReader(socket.getInputStream()));
    }

    static void initMainFrame(final DefaultTreeModel model,
    final JLabel countLabel, final String
    host){
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    final JFrame jframe = new JFrame("Groups: " + host);
    jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jframe.getContentPane().add(new JScrollPane(new JTree(model)),
    BorderLayout.CENTER);
    jframe.getContentPane().add(countLabel, BorderLayout.SOUTH);
    jframe.setLocationRelativeTo(null);
    jframe.pack();
    jframe.setVisible(true);
    }
    });
    }

    static String getGroupName(String line) {
    return new StringTokenizer(line).nextToken();
    }
    }

    class GroupNode extends javax.swing.tree.DefaultMutableTreeNode {
    HashMap<String, GroupNode> kids = new HashMap<String, GroupNode>();
    GroupNode(String name) {
    super(name, true);
    }
    GroupNode walkTo(DefaultTreeModel model, String child) {
    GroupNode node = kids.get(child);
    if (node == null) {
    node = new GroupNode(child);
    kids.put(child, node);
    add(node);
    model.nodesWereInserted(this, new int[] {children.size()-1});
    }
    return node;
    }
    }
    </sscce>
     
    Daniel Pitts, Jan 27, 2007
    #4
  5. Print Dude

    Print Dude Guest

    In article <>,
    says...
    > Out of curiousity, did you abandon Google because of their new look and
    > feel?
    > I don't like it myself, but I haven't bothered finding an alternative
    > yet.
    >
    >

    Pretty much my reasoning. I'm not sure I like Gravity all that much
    either. PAN on Linux is great so far.

    As I expected, the code you show later is way beyond me but it looks
    like someone with a fair amount of experience with Swing and networking
    and sockets could do it. I've got a long way to go...
     
    Print Dude, Jan 27, 2007
    #5
  6. Print Dude

    Print Dude Guest

    In article <>,
    says...
    > ..anyway, back to the ..already off-topic
    > thread.
    >

    .....which you never did respond to :) I know it's off topic, which is
    why I added OT to the subject line (isn't this the correct way to start
    a discussion which may be considered off-topic). Do you have anything
    that you can add to the discussion about newsreader client construction,
    in particular the process you would go through to come up with such a
    product?
     
    Print Dude, Jan 27, 2007
    #6
  7. On Jan 28, 1:01 am, Print Dude <> wrote:
    > In article <>,
    > says...
    > > ..anyway, back to the ..already off-topic
    > > thread.....

    > which you never did respond to :) I know it's off topic, which is
    > why I added OT to the subject line (isn't this the correct way to start
    > a discussion which may be considered off-topic).


    (shrugs) Yeah.. hey I was just going with your
    flow*, usually I do not even bother to mention
    when /I/ begin to take a conversation OT.

    (* Not that I regard discussions on posting
    tools to be off-topic for any NG.)

    >.. Do you have anything
    > that you can add to the discussion about newsreader client construction,
    > in particular the process you would go through to come up with such a
    > product?


    No. It is not my particular area of specialty, and
    it looks like Daniel has already posted code that
    would get you further than my sum total of
    knowledge of writing a news client.

    Andrew T.
     
    Andrew Thompson, Jan 27, 2007
    #7
  8. Print Dude

    Lew Guest

    I am partial to Mozilla Thunderbird.

    BTW, how is writing a newsgroup reader in Java OT for this group? Seems pretty
    on topic to me, but, hey.

    - Lew
     
    Lew, Jan 27, 2007
    #8
  9. Print Dude

    Print Dude Guest

    Hi, I copied and pasted your code into Eclipse but it won't run.
    Here's the error dump I get:

    java.lang.UnsupportedClassVersionError: Bad version number in .class
    file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass
    (SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Exception in thread "main"

    Any ideas? I've set the jdk to 1.6 and rebuilt the project a couple of
    times, to no avail.
     
    Print Dude, Jan 27, 2007
    #9
  10. Print Dude

    Print Dude Guest

    In article <>,
    says...
    > I am partial to Mozilla Thunderbird.
    >
    > BTW, how is writing a newsgroup reader in Java OT for this group? Seems pretty
    > on topic to me, but, hey.
    >
    > - Lew
    >

    Not sure. The idea of OO Design (the process, not the end result) may
    be considered Off-Topic by some. The FAQ (which I have read extensivly)
    talks about what is considered verboten and not, but it seemed to me as
    I was trying to formulate my question, that this would be the best forum
    to post in. It's not exactly a plea for help, so c.l.j.h would not
    work, neither would c.l.j.g And since these are the only 3 forums I
    subscribe to, the process of elimination left c.l.j.p
     
    Print Dude, Jan 27, 2007
    #10
  11. Print Dude

    Print Dude Guest

    > No. It is not my particular area of specialty, and
    > it looks like Daniel has already posted code that
    > would get you further than my sum total of
    > knowledge of writing a news client.
    >
    > Andrew T.
    >
    >

    Fair enough. But I am more interested in the process of OOD. I only
    used a newsreader as my example because it seemed to be a practical
    application of the methodology. Things have changed in the IT world
    since the days of the Yourdon Structured Design Course which I took back
    in 1990. I have a couple of books on design patterns, including
    HeadFirst, Design Patterns in Java and .... tada .... Essential Java (a
    book which I purchased at the recommendation of my instructor when I
    took a course in Java a couple of years ago).
     
    Print Dude, Jan 27, 2007
    #11
  12. Print Dude

    Print Dude Guest

    >
    > To follow up. in the last 30 minuts, I wrote a simple Swing application
    > that will download a list of newsgroups from my local provider, and
    > display them in a JTree.
    >

    Not sure why Eclipse had a problem with this, but running it from the
    command line with javac and java works perfectly.
     
    Print Dude, Jan 27, 2007
    #12
  13. Print Dude

    Alex Hunsley Guest

    Print Dude wrote:
    > Well I've abandoned google groups for the time being and have switched
    > over to PAN on Linux and Gravity on Windows. What I am wondering is,
    > how hard would it be to write a news reader client in Java?


    Not too hard, if you're comfortable with development up to a certain
    level. I've often thought of features I wish would appear in
    newsreaders/posters....

    > I know it's
    > way beyond me, but there must be people reading this ng who have had
    > some degree of sucess at it. What was the process you went through to
    > design and build the program? How much practical experience would one
    > need to be able to sucessfully code such a program? If you know that
    > you need say, a class that will send a request to a news server, how do
    > you go about finding it in the API documentation? And if you don't find
    > one, do you write your own or simply extend one that is already there,
    > and is close to what you need? I have a book on OO Design coming, but
    > it would be interesting to know what others think. I know this is
    > pseudo-off topic, which is why I put the OT in the subject line. This
    > is my first post using Gravity so it may not work, but if it does, I
    > hope we can have a good discussion about this topic, if it hasn't
    > already been hash(tabled) before.


    One of the important concerns is finding out about the core technology -
    news works via the NNTP protocol - and what is available to help you
    (e.g. APIs). When I googled for "java nntp api", I found a pointer to
    JavaMail:

    http://java.sun.com/developer/onlineTraining/JavaMail/contents.html

    From this page I found the following 3rd party JavaMail 'providers':

    http://java.sun.com/products/javamail/Third_Party.html

    ...from which I found a link to this:
    http://www.dog.net.uk/knife/

    ... and via the link to classpathx project I found, finally:

    http://www.gnu.org/software/classpathx/javamail/javamail.html

    This last page tells you about GNU JavaMail providers - they have an
    NNTP provider, which is an API you can use to read/post newsgroup
    messages...

    lex
     
    Alex Hunsley, Jan 28, 2007
    #13
  14. Print Dude

    Chris Smith Guest

    Print Dude <> wrote:
    > Not sure why Eclipse had a problem with this, but running it from the
    > command line with javac and java works perfectly.


    Sounds like a configuration problem; for example, perhaps you've got
    Eclipse running with a 1.5 JRE, but thinking it's a 1.6 JRE.

    --
    Chris Smith
     
    Chris Smith, Feb 10, 2007
    #14
  15. Print Dude

    Chris Smith Guest

    Print Dude <> wrote:
    > Not sure. The idea of OO Design (the process, not the end result) may
    > be considered Off-Topic by some.


    This group is pretty laid back compared to many others. You're
    generally welcome to discuss a lot of things here, so long as they are
    relevant to Java programming. You might start getting some complaints
    if you wanted to discuss OO design and post all your examples in
    Smalltalk; but design in general is fine.

    That's a commnunity norm. If you go over to comp.lang.c, you'll find a
    completely different set of rules (namely, that almost any imaginable
    question is considered off-topic there).

    --
    Chris Smith
     
    Chris Smith, Feb 10, 2007
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. arieljake
    Replies:
    3
    Views:
    341
    arieljake
    Feb 9, 2005
  2. Sharon

    OT: News Readers

    Sharon, Feb 24, 2004, in forum: HTML
    Replies:
    6
    Views:
    428
    Sharon
    Feb 25, 2004
  3. Johan
    Replies:
    15
    Views:
    874
    Johan
    Feb 27, 2004
  4. dancer

    Choose 1 or many

    dancer, May 16, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    357
    dancer
    May 18, 2007
  5. amith
    Replies:
    5
    Views:
    149
    Thomas 'PointedEars' Lahn
    Nov 28, 2003
Loading...

Share This Page