方法 1. java后台访问url,通过默认浏览器打开 (不建议)
private static void browse(String url) throws Exception {
//获取操作系统的名字
String osName = System.getProperty("os.name", "");
if (osName.startsWith("Mac OS")) {
//苹果的打开方式
Class fileMgr = Class.forName("com.apple.eio.FileManager");
Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class });
openURL.invoke(null, new Object[] { url });
}else if(osName.startsWith("Windows")) {
//windows的打开方式。
try{
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
}catch(Exception e2){ e2.printStackTrace();}
}else{
// Unix or Linux的打开方式
String[] browsers = { "firefox", "opera", "konqueror"