I made a simple AWT program and made it as a jar file using eclipse on windows machine. After making jar, i sent it to my Centos virtual machine and used ssh to login. When i tried to execute the program, it provides no reply.
I installed Xvfb in Centos and set the DISPLAY variable as well.
X11 forwarding is also enabled on PUTTY
Java code:
public class TestAWT{
TestAWT()
{
JFrame test = new JFrame();
test.setVisible(true);
test.setSize(100,100);
test.setResizable(false);
test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String args[])
{
new TestAWT();
}
}
Execution command:
java -jar testawt.jar
java -jar -Djava.awt.headless=true testawt.jar -> Throwed Headless Exception
Could some please advise how to solve this problem?
Copyright Notice:Content Author:「Dev」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/34291634/java-frame-awt-does-not-appear-on-program-execution-in-centos