• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Launching telnet using java program fails with Win 7 OS

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there an exception / stack trace that can be shared?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 80622
469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22849
132
Eclipse IDE Spring Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK.. My JVM is 32 bit. I will try by installing 64 bit JVM and check the result.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 80622
469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic