public JLabelDemo() throws Exception{
super();
this.setTitle("哈哈");
this.setBounds(100, 100,500,500);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//System.out.println("hhh");
JLabel jLabel=new JLabel();
jLabel.setToolTipText("上海海洋大学");
jLabel.setDisplayedMnemonic('0');
jLabel.setHorizontalAlignment(SwingConstants.CENTER);
jLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
jLabel.setText("<html><body><font size=10pt><a href=http://www.baidu.com>上海海洋大学</a></font></body></html>");
jLabel.addMouseListener(new java.awt.event.MouseAdapter(){

public void mouseReleased(MouseEvent e){
jLabel_mouseReleased(e);
      }
void jLabel_mouseReleased(MouseEvent e){
try {
     System.out.println("");
Runtime.getRuntime().exec("cmd/c start http://www.baidu.com");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();}
}
}
);
this.add(jLabel);
}调试出现如下错误电脑是win7 32位系统exception

解决方案 »

  1.   

    默认的GBK,换成UTF-8、ISO都没用
    我怀疑是这里出了错Runtime.getRuntime().exec("cmd/c start http://www.baidu.com");
      

  2.   

    这样玩就好..try {
    Runtime.getRuntime().exec(new String[]{"cmd","/c","start http://www.baidu.com"});
    } catch (IOException e) {
    e.printStackTrace();
    }
      

  3.   

    "cmd/c"命令有问题,应该写成"cmd /c"
    希望接受答案之后多给点分数