Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Telnet invocation via Java code using apache commons net jar

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..

 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic