| View previous topic :: View next topic |
| Author |
Message |
ellias2007
Joined: 12 Feb 2009 Posts: 31
|
Posted: Mon Mar 15, 2010 5:41 pm Post subject: main class problem |
|
|
Hi all,
in my NetBeans 8.6, i choosed :
File menu > New Project
Categories : Java
Projects : Java Application
next
i fill the Project Name and CHECK the "create Mail class" CheckBox
Finish
i write a simple code like this :
| Code: | package mypckg;
import javax.swing.*;
import java.awt.*;
public class Main {
static JFrame theJFrame;
static Container c;
public static void main(String[] args) {
theJFrame = new JFrame("JFrame Title");
theJFrame.setSize(200,200);
c = theJFrame.getContentPane();
}
} |
BUT : When i try to run the code i get the message :
mypckg.Main class was not found in trydist1 project
<No main classes found>
Any one tell me what is the problem? and are there conditions for a class to be a main class??
Many Thanks |
|
| Back to top |
|
 |
Javier.Ortiz Posted via mailing list.
|
Posted: Mon Mar 15, 2010 5:48 pm Post subject: main class problem |
|
|
Right click the project>Properties>Run
Select the main class from there. I thought that checking the create main class did this automatically...
Javier A. Ortiz Bultr |
|
| Back to top |
|
 |
ellias2007
Joined: 12 Feb 2009 Posts: 31
|
Posted: Mon Mar 15, 2010 6:00 pm Post subject: |
|
|
Thanks for your quick reply,
when i went to properties>Run, i found already in the field "Main class" : mypckg.Main...
and also when i click the Browse button at right, i get in the "Browse Main classes" window :
Main classes : <No main classes found>
... it is really ubnormal! |
|
| Back to top |
|
 |
Javier.Ortiz Posted via mailing list.
|
Posted: Mon Mar 15, 2010 7:18 pm Post subject: main class problem |
|
|
At least on daily build ot works fine.
Make sure there's a line main.class in nbproject/project.properties.
Javier A. Ortiz Bultr |
|
| Back to top |
|
 |
ellias2007
Joined: 12 Feb 2009 Posts: 31
|
Posted: Mon Mar 15, 2010 8:02 pm Post subject: Re: main class problem |
|
|
| Quote: | | Make sure there's a line main.class in nbproject/project.properties. |
YES, this line exists (main.class=mypckg.Main)
also, there is a manifest file in witch i found written :
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Thanks for any help |
|
| Back to top |
|
 |
etech
Joined: 18 Mar 2010 Posts: 1
|
Posted: Thu Mar 18, 2010 5:04 am Post subject: |
|
|
Hi,
I am having this same problem. It seems that the constructor method must be static, otherwise the main class ceases to be the main class after saving.
For instance, having the constructor for class NewMain as:
| Code: | public static void main(String[] args) {
} |
..keeps the class as the main class. Whereas, changing the method to:
| Code: | public void main(String[] args){
} |
..causes the class to become a non-main class after saving.
Is this a bug?
etech
Product Version: NetBeans IDE 6.8 (Build 200912041610)
Java: 1.6.0_18; Java HotSpot(TM) Client VM 16.0-b13
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb) |
|
| Back to top |
|
 |
Bayless Kirtley Posted via mailing list.
|
Posted: Thu Mar 18, 2010 1:53 pm Post subject: main class problem |
|
|
Not a bug but a Java requirement. After you make that change, it is not even
a proper main method.
----- Original Message -----
From: "etech" <address-removed>
To: <address-removed>
Sent: Thursday, March 18, 2010 12:04 AM
Subject: [nbusers] main class problem
| Quote: | Hi,
I am having this same problem. It seems that the constructor method must
be static, otherwise the main class ceases to be the main class after
saving.
For instance, having the constructor for class NewMain as:
Code:
public static void main(String[] args) {
}
..keeps the class as the main class. Whereas, changing the method to:
Code:
public void main(String[] args){
}
..causes the class to become a non-main class after saving.
Is this a bug?
etech
Product Version: NetBeans IDE 6.8 (Build 200912041610)
Java: 1.6.0_18; Java HotSpot(TM) Client VM 16.0-b13
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
|
|
|
| Back to top |
|
 |
|