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.
精彩评论