开发者

launching my application using the main method

开发者 https://www.devze.com 2023-01-16 22:16 出处:网络
I have used Netbeans to create a swing arm project. How do i use the main method to launch my applicati开发者_高级运维on?public static void main(String[] args){

I have used Netbeans to create a swing arm project. How do i use the main method to launch my applicati开发者_高级运维on?


public static void main(String[] args){
    EventQueue.invokeLater(new Runnable(){
        public void run(){
            new TutoringWages().setVisible(true);
        }
    });
}

This should be a method inside your class. For example,

package pkg.to.tw;
public class TutoringWages extends JFrame {
    public static void main(String[] args){
        EventQueue.invokeLater(new Runnable(){
            public void run(){
                new TutoringWages().setVisible(true);
            }
        });
    }
    //more code such as constructors, field methods, etc.
    //...
} //finally the end.

Netbeans automatically builds a jar for you. In netbeans push clean and build, which will generate a jar file in the dist folder of the project. If you aren't using this great feature, then you can do this:

cd src
javac pkg/to/tw/TutoringWages.java
java pkg.to.tw.TutoringWages

Then in runs. Do not include the .class extension in the java command. It will produce errors.

0

精彩评论

暂无评论...
验证码 换一张
取 消