Strange behavior with java from command line
<SOLVED>
Evening. Have a small issue. I use NetBeans when i code. It has made a nice Jar file. When i start it using java -jar path class.jar it starts but freeze at main frame. Cant click on the x to close it. All menus and other swing items dont show.
So i re compiled it from a new directory with fresh .java files using javac *.java from comand line. With the same result.
Confused I start NetBeans again. and there it works perfect. What does NetBeans do that i dont? or that i need to do. :confused:
I Have also comment out everything and only compiled only Main.java as shown below, with same result.
Have now tryed diffrent thing.
One i created a new class with only System.out.print("hello"); Works fine.
Two. added a simple JFrame with basic parameters. Little Buggy. wont close on x
every time.
Three tryed added one of my orginal classes, it shows but freeze. and it uses another font then in NetBeans.
Mabey need to re install my java ?
Code:
import java.awt.Dimension;
import javax.swing.*;
public class Main {
Main(){
mstFrame();
}
private JFrame mstFrame () {
JLabel label = new JLabel("hello");
JFrame mstFrame = new JFrame("Mst");
// JTabbedPane mstTabPane = new JTabbedPane();
// mstTabPane.addTab("Start", new Welcome());
// mstTabPane.addTab("Create Project", new CreateProject());
// mstTabPane.addTab("Customer", new Customer());
// mstTabPane.addTab("Product", new Product());
mstFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// mstFrame.setSize(new Dimension(1010,620));
// mstFrame.setLocationRelativeTo(null);
// mstFrame.add(mstTabPane);
mstFrame.setVisible(true);
mstFrame.pack();
return mstFrame;
}
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable(){
public void run(){
new Main();
}
}
);
}
}