Dear All Ubuntian:
i new to ubuntu (ubuntu 12.04LTS)and just started to learn java program.
i confuce with java program , i create program , set it to executable file, it run properly on eclipse (IDE) and terminal(after i export it) , but when i doubleclick to run nothing happen, anyone know why?? code as below:
<java code>
import javax.swing.*;import java.awt.HeadlessException;
import java.io.*;
public class h {
/**
* @param args
* @throws IOException
* @throws HeadlessException
*/
public static void main(String[] args) throws HeadlessException, IOException {
// TODO Auto-generated method stub
String a="";
InputStream s=new FileInputStream("data.xml");
int size=s.available();
for(int j=0;j<size;j++){
a=a+(char)s.read();
}
JOptionPane.showMessageDialog(null,a);
}
}
<java code end>
so i wrote another program to launcher this using Runtime.getRuntime().Exec(); method with a JOptionPane.showMessageDialog(null, "open h.jar").
When i double click it didn't launch my h.jar but the message show up, when i run with terminal every thing work fine , can anyone help me with this(confuse big time)?Code as below:
<java code>
import java.io.IOException;
import javax.swing.*;
public class launcher {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
JOptionPane.showMessageDialog(null, "open h.jar");
@SuppressWarnings("unused")
Process p=Runtime.getRuntime().exec("java -jar h.jar");
}
}
<java code end>
Thank
Bookmarks