so I am a new programmer, I have been programming for about, probably a little over one month now. I am developing a fun program that asks for a username and password, once correct, the program allows the user to enter a command that can do something. I have found that using the Process class, and using the code Runtime.getRuntime().exec(""); opens a application, but is static in the sense that it the directory may not be the same for every person who uses it. How can I make this dynamic? How can I make it so the user can input their directory or even the program can detect the directory by itself?
Some code from my main class:
while (caseValidation.caseCheckFlag == true) {
caseValidation.SetCase();
if (caseValidation.GetCase().equalsIgnoreCase("internet"))
{
System.out.println("Command executed!");
intCMD.fetchInternet();
}
else if (caseValidation.GetCase().equalsIgnoreCase("spotify"))
{
System.out.println("Command executed!");
musCMD.fetchSpotify();
}
else if (caseValidation.GetCase().equalsIgnoreCase("changeUsername"))
{
//code here
}
else if (caseValidation.GetCase().equalsIgnoreCase("changePass"))
{
//code here
}
else if (caseValidation.GetCase().equalsIgnoreCase("pictures"))
{
//code here
}
else if (caseValidation.GetCase().equalsIgnoreCase("videos"))
{
//code here
}
else if (caseValidation.GetCase().equalsIgnoreCase("music"))
{
//code here
}
else if (caseValidation.GetCase().equalsIgnoreCase("documents"))
{
//code here
}
// more cmds here in the future
InternetCMD Class:
public class InternetCMD {
public void fetchInternet() throws IOException {
Process internet = Runtime.getRuntime().exec("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
}
}
Thanks for any advice in advance! :D