I am using the Apache commons-net lib to telnet into a PC. After I am done connecting to this server, I want to be able to execute commands on it(server). What is the best way to achieve this in Java?
You're better off using JSch to telnet to your remote machine and execute the commands. Checkout the examples sections - it has everything you need.