Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to get the path of a selected file in explorer.exe. I need it from something System Variable or somewhere as I can read in with a java application.

share|improve this question

There isn't a system level attribute that will allow you to observe the selected file. there are a couple options, but both are pretty big detours.

the most traditional approach is to have your java app spawn the window in question, via some API that allows you to retrieve the file information on some event. the jFileChooser is one of these.

another approach is to leverage the windows API directly. you would need to capture the window handle of the windows explorer instance and inspect it with an object like ShellWindows. see some more info here:

not sure how to interface with the winAPI via java, but I;m sure there's a way.

This probably belongs on StackOverflow instead of SU.

share|improve this answer
the first link you gave me, is not a java code, how can i translate it? – night_angel90 Feb 20 '13 at 13:49
windows API code is never going to be in java, but there should be an interface you can use to access it via the JDK. here is some general info about importing a windows api dll, and invoking its members: – Frank Thomas Feb 20 '13 at 14:22
@night_angel90: I think what you're looking for based on Frank's suggestion is JNI. – Karan Feb 21 '13 at 4:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.