IM试图运行此代码,该代码使用事件执行jar文件但不起作用
我如何解决
IM试图运行此代码,该代码使用事件执行jar文件但不起作用
我如何解决
JButton cn= new JButton("push me3");
cn.setBounds( 0,0,295,20 );
f.add(cn);
cn.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
String title =hellopanelx40.getText();
try{
//All your IO Operations
Process proc = Runtime.getRuntime().exec("/home/example.jar");
proc.waitFor();
// Then retreive the process output
InputStream in = proc.getInputStream();
InputStream err = proc.getErrorStream();
byte b[]=new byte[in.available()];
in.read(b,0,b.length);
System.out.println(new String(b));
byte c[]=new byte[err.available()];
err.read(c,0,c.length);
System.out.println(new String(c));
}catch(Throwable t){
t.printStackTrace();
}
}
});
请帮帮我
答案 0 :(得分:0)
在exec()中,尝试更改“java -jar /home/example.jar”