参考代码如下:
package demo;
import java.util.Properties;
import java.io.IOException;
public class OpenIExplore{
public static void main(String[] args) throws IOException{
Properties properties = System.getProperties();
String osName = properties.getProperty("os.name");
System.out.println (osName);
if (osName.indexOf("Linux") != -1) {
Runtime.getRuntime().exec("htmlview");
} else if (osName.indexOf("Windows") != -1){
Runtime.getRuntime().exec("explorer http://www.baidu.com");
} else {
throw new RuntimeException("Unknown OS.");
}
}
}
是不是运行外部程序ie。
import java.io.IOException;
public class test {
public static void login(){
Runtime rt = Runtime.getRuntime();
try {
rt.exec("rundll32 url.dll,FileProtocolHandler " + "http://www.baidu.com");
} catch (IOException e) {
}
}
public static void main(String[] args) {
login( );
}
}