| Author |
Launching telnet using java program fails with Win 7 OS
|
Sham Phadtale
Ranch Hand
Joined: Jul 29, 2008
Posts: 75
|
|
I have sample program which launches telnet on Windows XP OS.
In Win 07 we need to manually turned on telnet option. I did it. I able to launch telnet from cmd but above java program fail to launch telnet on Win 7.
What I need to do to launch telnet using Java on Win 7?
|
 |
Brian Burress
Ranch Hand
Joined: Jun 30, 2003
Posts: 118
|
|
|
Is there an exception / stack trace that can be shared?
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12269
|
|
Where are you consuming std out and std err and providing std in streams? Read the javadocs for java.lang.Process
Bill
|
Java Resources at www.wbrogden.com
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
|
. . . and the classic article which you can find by Googling for Michael Daconta when Runtime.exec() won't.
|
 |
Sham Phadtale
Ranch Hand
Joined: Jul 29, 2008
Posts: 75
|
|
Thanks all for your quick replies.
I read the classic article. I updated the code as given in article as -
I am getting following out put
Execing cmd.exe /C telnet
ERROR>'telnet' is not recognized as an internal or external command,
ERROR>operable program or batch file.
ExitValue: 1
I can run telnet by opening Start--->cmd---->telnet but not through java program.
What I need to do to run telnet from Java program?
|
 |
John Jai
Bartender
Joined: May 31, 2011
Posts: 1778
|
|
You might consider using the Apache Commons Net package. It lists Telnet in the supported protocol. This examples guide can help you start.
Note that while executing telnet you fork a sub-process from the cmd.exe. Try giving the dir command in your code and check if it works first with the cmd.
|
 |
Sham Phadtale
Ranch Hand
Joined: Jul 29, 2008
Posts: 75
|
|
dir works from my Java program, it opens command prompt and shows directories.
I will check Apache Commons Net package.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Are you using a 32-bit JVM?
I've tried it on my system as well without Java. I opened CMD from the start menu which will then open a 64-bit CMD window. Telnet works in it. I then opened CMD from Total Commander. Since Total Commander is 32-bit, it launches a 32-bit CMD. Telnet does not work in that. Apparently, on a 64-bit Windows 7 system, telnet only works when launched from a 64-bit application.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Sham Phadtale
Ranch Hand
Joined: Jul 29, 2008
Posts: 75
|
|
Telnet works with CMD but does not work when launch from java program.
|
 |
John Jai
Bartender
Joined: May 31, 2011
Posts: 1778
|
|
I guess Rob tells that telnet does not launch from a 32-bit JVM and only on a 64-bit JVM (in case of Win7 i believe). What is the bit version of the JVM that executes your java program and that invokes the cmd.exe?
Which one listed here is that you have - x86 or x64?
|
 |
Sham Phadtale
Ranch Hand
Joined: Jul 29, 2008
Posts: 75
|
|
|
OK.. My JVM is 32 bit. I will try by installing 64 bit JVM and check the result.
|
 |
 |
|
|
subject: Launching telnet using java program fails with Win 7 OS
|
|
|