How do I set the path from user input for a new process using ProcessBulder?

StackOverflow https://stackoverflow.com/questions/23166474

  •  06-07-2023
  •  | 
  •  

سؤال

I want to add new process using ProcessBulder class in Java. But process name is taken from user input then how to set the path?

The user only enter the process name like firefox.exe, but it does not start directly, it throws PathNotFoundException. How can I identify the path of user's input? Or how should I start the process which entered by the user?

هل كانت مفيدة؟

المحلول

It should be either full path or the program should be in a folder known to OS via PATH variable, or the program should be in working dir

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top