Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Java Runtime.exec() where does command get executed?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This code works and opens notepad.exe under windows 10. Where does this command actually get executed under Windows 10? with which command line interpreter program? cmd ? powershell?
 
Veli Yücel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or does java only check PATH and run the program if it exists there. Anyone who knows whats going on when a command executed with exec()? I'm just confused because it takes a command string as parameter but commands are specific to interpreter. Which commands are acceptable by exec() function under Windows 10?
 
Sheriff
Posts: 13553
223
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can just cut to the chase and run cmd.exe /C from Java or do whatever you'd need to do to run PowerShell.  See the GoodWindowsExec example here: http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html?page=2
 
Marshal
Posts: 65034
247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and welcome to the Ranch
 
Happily living in the valley of the dried frogs with a few tiny ads.
Java Code Review and Psychology
https://coderanch.com/t/714798/java/Java-Code-Review-Psychology
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!