my dog learned polymorphism*
The moose likes Java in General and the fly likes Telnet invocation via Java code using apache commons net jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Telnet invocation via Java code using apache commons net jar" Watch "Telnet invocation via Java code using apache commons net jar" New topic
Author

Telnet invocation via Java code using apache commons net jar

vetrivendhan rajamanoharan
Greenhorn

Joined: Apr 10, 2013
Posts: 11
All,

Please let me know how do I inovke Telnet prompt via Java code using apache commons net jar .

I have done the following code

String command = "cmd /c start cmd.exe /K \"telnet <ip-address> \"";
Process process = Runtime.getRuntime().exec(command);

It works fine for 64 bit JRE with 64 bit Telnet client(Win 7 64 bit OS)

But it fails while i use 32 bit jre..

How do i achieve the 364 bit telnet client via 32 bit JRE

I read in the posts it can be done using Apache commons class..

Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
What does Runtime.getRuntime().exec have to do with apache commons net?
vetrivendhan rajamanoharan
Greenhorn

Joined: Apr 10, 2013
Posts: 11
All,

Please any one have the idea about invoking the Win 7 64 bit telnet client via Java Runtime.exec(). on 32 bit JRE

String command = "cmd /c start cmd.exe /K \"telnet 10.78.241.20\"";

` Process proc = Runtime.getRuntime().exec(command);

It throws "telnet' is not recognized as an internal or external command, operable program or batch file."

But in case if the same above statements run on 64 bit JRE it works fine.

Kindly light up me on this

Thnks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42360
    
  64
Start by using Runtime.exec(String[]) instead of Runtime.exec(String). If that doesn't help, read through this article and follow all its advice.


Ping & DNS - my free Android networking tools app
vetrivendhan rajamanoharan
Greenhorn

Joined: Apr 10, 2013
Posts: 11
String[] cmd = {"cmd.exe", "/start","\"telnet","10.78.241.20\""};

Process proc = Runtime.getRuntime().exec(cmd);

It's not working
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42360
    
  64
You've done all this:
this article and follow all its advice.

?

If so, post your complete code.
vetrivendhan rajamanoharan
Greenhorn

Joined: Apr 10, 2013
Posts: 11
At last, found the solution by someway.

Copy the "telnet.exe" file from C:\Windows\System32 folder to C:\Windows\SysWOW64

Post this operation, telnet prompt got opened while it executed via 32 bit JRE even though telnet client is specific to operation system. i.e 64 bit.

String command = "cmd /c start cmd.exe /K \"telnet <ip-address> \"";
Runtime.getRuntime().exec(command);

Ref : http://en.wikipedia.org/wiki/WoW64
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Telnet invocation via Java code using apache commons net jar