Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How to run Telnet Command in java?

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Thanked 0 Times in 0 Posts

    Default How to run Telnet Command in java?

    How to run Telnet Command in java?
    plz anyone help me.

  2. #2
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    South England UK
    My Mood
    Thanked 61 Times in 55 Posts

    Default Re: How to run Telnet Command in java?

    I would think it would need

    import java.net.*

    Have you tried Googling the term in relation to Java? All I
    know is it has something to do with Socket programming, but
    you can certainly find useful information with a simple search.

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    Augusta Ada Byron, Lady Lovelace (1851)

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 688 Times in 675 Posts

    Default Re: How to run Telnet Command in java?

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

  4. #4
    Member jdv's Avatar
    Join Date
    Jul 2014
    This Land
    Thanked 5 Times in 5 Posts

    Default Re: How to run Telnet Command in java?

    You have two approaches:

    1. "exec" out to a system shell to call the telnet client with all the right environment and arguments, do the work and capture the output and any return codes. (For example, if all you had to do was an automated exchange with a foreign telnet host.)

    2a. Write a telnet application in Java that does what you need, and then write the client code around that.
    2b. Find a telnet/ssh/scp library you can leverage, and write your client code around that.

    (1) is crufty, highly system dependent, and brittle. But it can get the job done in a pinch if you need something quick and dirty. (2a) is probably over-kill. (2b) is doable, but you have to find the library for you. There used to be some non-free Java telnet/ssh libraries I used to make an ssh applet, and such things still exist for all browsers, so this implies there are more than a few telnet/ssh libraries out there you can leverage.

    Final note: don't use telnet. Use ssh. Another hint: don't ever use telnet.

Similar Threads

  1. My Java program is failing to run in command prompt
    By George Mawire in forum What's Wrong With My Code?
    Replies: 26
    Last Post: January 24th, 2014, 06:54 AM
  2. Java Child process cannot execute properly for telnet command
    By mamunbu in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 25th, 2011, 07:43 AM
  3. Run command line structure in Java
    By soheilz92 in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: April 20th, 2011, 02:26 AM
  4. Run 2 systems command in applet, how?
    By bulgin in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 8th, 2010, 03:11 PM
  5. opening Telnet Command Session
    By voyager in forum Java Networking
    Replies: 3
    Last Post: June 23rd, 2009, 10:34 AM