자바로 디폴트 브라우저 기동시키기(java default browser start)예제소스입니다. 자바공부 열심히 하세요~
package onj;
import java.io.IOException;
public class MyBrowser {
public static void main(String[] args) {
displayURL();
}
public static void displayURL() {
public static void main(String[] args) {
displayURL();
}
public static void displayURL() {
String cmd = null;
try {
if (System.getProperty("os.name").startsWith("Windows")) {
cmd = "rundll32 url.dll,FileProtocolHandler http://www.oraclejavanew.kr";
Process p = Runtime.getRuntime().exec(cmd);
} else {
// 유닉스라면 netscape -remote openURL(http://www.oraclejavanew.kr)
Process p = Runtime.getRuntime().exec("netscape -remote openURL(http://www.oraclejavanew.kr)");
try {
// waitFor의 결과코드값이 0 이면 브라우저 떠있는 것, 아니면 브라우저 시작 시킴
if (p.waitFor() != 0) {
cmd = "netscape http://www.oraclejavanew.kr";
p = Runtime.getRuntime().exec(cmd);
}
} catch(InterruptedException x) {
System.err.println("Error :: " + cmd);
System.err.println("Caught: " + x);
}
}
} catch(IOException e) {
System.err.println("browser invoke error :: " + cmd + e);
}
}
}
try {
if (System.getProperty("os.name").startsWith("Windows")) {
cmd = "rundll32 url.dll,FileProtocolHandler http://www.oraclejavanew.kr";
Process p = Runtime.getRuntime().exec(cmd);
} else {
// 유닉스라면 netscape -remote openURL(http://www.oraclejavanew.kr)
Process p = Runtime.getRuntime().exec("netscape -remote openURL(http://www.oraclejavanew.kr)");
try {
// waitFor의 결과코드값이 0 이면 브라우저 떠있는 것, 아니면 브라우저 시작 시킴
if (p.waitFor() != 0) {
cmd = "netscape http://www.oraclejavanew.kr";
p = Runtime.getRuntime().exec(cmd);
}
} catch(InterruptedException x) {
System.err.println("Error :: " + cmd);
System.err.println("Caught: " + x);
}
}
} catch(IOException e) {
System.err.println("browser invoke error :: " + cmd + e);
}
}
}
| 12-27 | 2624 | |||
| 12-11 | 1895 | |||
| 53 | 03-15 | 1714 | ||
| 52 | 01-31 | 1823 | ||
| 51 | 01-31 | 2674 | ||
| 50 | 01-31 | 1428 | ||
| 49 | 01-19 | 1751 | ||
| 48 | 01-11 | 1638 | ||
| 47 | 01-03 | 2154 | ||
| 46 | 12-27 | 2624 | ||
| 45 | 12-19 | 1858 | ||
| 44 | 12-14 | 1828 | ||
| 43 | 12-11 | 1895 | ||
| 42 | 12-09 | 1489 | ||
| 41 | 12-01 | 1718 | ||
| 40 | 12-01 | 1897 | ||
| 39 | 12-01 | 1363 | ||
댓글 없음:
댓글 쓰기