Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Launching telnet using java program fails with Win 7 OS

 
Sham Phadtale
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there an exception / stack trace that can be shared?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you consuming std out and std err and providing std in streams? Read the javadocs for java.lang.Process

Bill
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and the classic article which you can find by Googling for Michael Daconta when Runtime.exec() won't.
 
Sham Phadtale
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dir works from my Java program, it opens command prompt and shows directories.

I will check Apache Commons Net package.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sham Phadtale
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Telnet works with CMD but does not work when launch from java program.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK.. My JVM is 32 bit. I will try by installing 64 bit JVM and check the result.
 
sandra pinkie
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sham Phadtale wrote:OK.. My JVM is 32 bit. I will try by installing 64 bit JVM and check the result.


hello, I have the same problem and I would like to know if you already know how to fix it.
Thank you!
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You may not get a reply soon since the original poster has not posted anything for over a year.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic