Not hard coding the iexplorer path

Hi

I was looking around and saw this piece of code posted by Cotton.m:

publicclass IETest{

publicfinalstatic String browserPath ="C:\\Program Files\\Internet Explorer\\iexplore.exe";

publicstaticvoid main(String args[])throws Exception{

String[] urls ={"http://forum.java.sun.com","http://www.cnn.com","http://www.google.com"};

for(int i=0;i<urls.length;i++){

launchPage(urls[i]);

}

}

publicstaticvoid launchPage(String pageName)throws Exception{

String[] launchPath =new String[2];

launchPath[0] = browserPath;

launchPath[1] = pageName;

Runtime.getRuntime().exec(launchPath);

}

}

Does anyone know how to not hardcode the browserPath? or is that impossible... I'm doing something similar but I open files... is there a way that I don't need to hard code the path name? or am i asking too much?

Cheers>

[1826 byte] By [singstara] at [2007-10-3 4:49:33]
# 1
[url http://forum.java.sun.com/thread.jspa?threadID=767764&tstart=0]Crosspost.[/url]
CaptainMorgan08a at 2007-7-14 22:54:04 > top of Java-index,Java Essentials,Java Programming...
# 2

/*

** Here is a pure Windows solution

**

** Run the code and you will be taken to a tutorial that may provide

** a more generic solution

*/

public class WindowsProcess

{

public static void main(String[] args)

throws Exception

{

String[] cmd = new String[4];

cmd[0] = "cmd.exe";

cmd[1] = "/C";

cmd[2] = "start";

cmd[3] = "http://www.javaworld.com/javaworld/javatips/jw-javatip66.html";

//cmd[3] = "notepad";

//cmd[3] = "will.xls";

//cmd[2] = "a.html";

//cmd[3] = "file:/c:/java/temp/a.html";

Process process = Runtime.getRuntime().exec( cmd );

}

}

camickra at 2007-7-14 22:54:04 > top of Java-index,Java Essentials,Java Programming...