How To Perform a Telnet Operation from a Java Application

How To Perform a Telnet Operation from a Java Application

Follow these simple steps to perform a telnet operation from a Java application:

  1. Download the free API, jta20.jar.
  2. Set the file in the classpath:
    public class TestTelnet{  public static void main(String args[]){        //instantiate the telnet wrapper class        TelnetWrapper telnetWrapper = new TelnetWrapper();        try {            //connect to the ipaddress            telnetWrapper.connect("", 23);            //username and pwd of the ipaddress            telnetWrapper.login("username", "pwd");            //this is the prompt appears when doing normal ftp using cmd prompt.            telnetWrapper.setPrompt("ftpprompt$");           //wait for the prompt           telnetWrapper.waitfor("bash-2.03$");           //execute the commands           System.out.println(telnetWrapper.send("ps -ef | grep java"));        }catch( e){           e.printStackTrace();        }  }}

See also  How to Avoid Money Transfer Scams  

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist