Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Not hard coding the iexplorer path

807569Sep 12 2006 — edited Sep 12 2006
Hi

I was looking around and saw this piece of code posted by Cotton.m:
public class IETest{
 
  public final static String browserPath ="C:\\Program Files\\Internet Explorer\\iexplore.exe";
 
  public static void 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);	
}
}

public static void 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>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 10 2006
Added on Sep 12 2006
2 comments
130 views