• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How to open command prompt from a java program  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to open command prompt from a java program..

please give me the code..

PC
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a read of the JavaDocs for Runtime.exec. Also, have a search through this forum for references to Runtime.exec. You should find plenty example code.
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I tried but none of line 1, 2 or 3 starts a command prompt. I think from command prompt, I am running this program, so thats why it won't start a new process.



Naseem
 
Bartender
Posts: 9559
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you type those commands into a prompt? Do they open a new command prompt?
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It does nothing. With the above code it does not open a new command prompt.
[ July 11, 2006: Message edited by: Naseem Khan ]
 
Joe Ess
Bartender
Posts: 9559
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right. So the problem isn't with Java, it's with your use of the command line. First you should set out to discover what command will create a new window. A simple web search led me to this handy reference. Once you have the command, you'll still need a command interpreter to run it, so your exec line should include a call to it. Let us know what you try and if you are still stumped.
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe,

With your reference and little r&d, it worked.

Code below:



Thanks
[ August 06, 2006: Message edited by: Naseem Khan ]
 
No more fooling around. Read this tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!