Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Telnet invocation via Java code using apache commons net jar

 
vetrivendhan rajamanoharan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 981
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does Runtime.getRuntime().exec have to do with apache commons net?
 
vetrivendhan rajamanoharan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
vetrivendhan rajamanoharan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String[] cmd = {"cmd.exe", "/start","\"telnet","10.78.241.20\""};

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

It's not working
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've done all this:
this article and follow all its advice.

?

If so, post your complete code.
 
vetrivendhan rajamanoharan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic