• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

start a file explorer in win and after 2 seconds "kill it" in java?

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I want so
open a fileexplorer (with a path)
and then close it after 2 seconds, how do i do this in java?

if i ude the bach in CMD this works to kill all :

but not in java :-(

the big problem is that if i only kill explorer.exe the shell
with the startmeny and so on is altso killed :-(

so the code (no try catch here but i have this on the "real code"..):


this program open the file explorer in the C:/folder
then wait some time then "nothing"!

but if I run this (see bellow) the fileexplorer closed but also win shell close :-(



:-(

(and then make this run when I have make a jar file on this)
 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor 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
The first thing I notice is that you're calling waitFor() without making sure that the process' output buffers are cleared. You should read When Runtime.exec() won't. The article is old, but apart from not mentioning ProcessBuilder (using redirectErrorStream(true) can make life a bit easier) it's still very relevant.
 
Marshal
Posts: 76854
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A ProcessBuilder object can redirect the streams to make their emptying easier, but it has not changed the principles in the Daconta article which Rob gave you a link to.
 
The knights of nee want a shrubbery. And a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic