Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am making a program that will open a specific browser (not just my default) an

ID: 3528651 • Letter: I

Question

I am making a program that will open a specific browser (not just my default) and go to a specified URL and i need it to work on other computers, not just mine. Everything works but I can't seem to get my program to find the .exe to open the browser without having to enter the whole file path which restricts this program to just my computer. Also I am using Eclipse and I am exporting the program as a jar executable. My Question is how can i find the browser's .exe file on someone else's computer? Here are some ideas that I had: 1. I tried this: Runtime.getRuntime().exec("firefox.exe http://www.website.com"); this didn't work, i got and error saying that firefox.exe could not be found. 2. I was thinking that I could make a relative file path. For example, C://firefox.exe. This did not work for me but i could have done it wrong. 3. I then tried this bit of code to get the absolute file path of firefox.exe: File file = new File("firefox.exe"); String filePath = file.getAbsolutePath(); this seem like it would work but i just made a file called "firefox.exe" in my eclipse workspace and retrieved the path to that file. This is not what i want because I am trying to find something that already exists on the computer. I feel that getAbsolutePath() is my best option if i can find a way to use it without having to create a new file but if there is a better option like a solution to idea 1 or 2 above or a completely new option then please post it. Please make sure to put sample code of the option that you provide because I am not the most proficient at java so I may not get all the terminology. Also DO NOT COPY YOUR ANSWER FROM SOMEWHERE ELSE, I want a answer that is specific to my question and not a post made on a forum online that answered a similar question.

Explanation / Answer

try

Runtime.getRuntime().exec("cmd /c starthttp://www.website.com");