This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 48163 - Cannot set a second top-level class as the main class for a j2seproject
Summary: Cannot set a second top-level class as the main class for a j2seproject
Status: RESOLVED INVALID
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 4.x
Hardware: All All
: P4 blocker (vote)
Assignee: Jiri Rechtacek
URL:
Keywords:
Depends on:
Blocks: 41537
  Show dependency tree
 
Reported: 2004-08-30 13:48 UTC by pzgyuanf
Modified: 2004-10-29 14:37 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample source code (648 bytes, text/plain)
2004-08-30 14:36 UTC, Petr Hrebejk
Details

Note You need to log in before you can comment on or make changes to this bug.
Description pzgyuanf 2004-08-30 13:48:07 UTC
cannot run from inner class:
	----------------------------------------
	public class Test {
	  static String s = "sss";
	}
	
	class SubTest extends Test {
	  static int  s = 1;
	
	  public static void main(String[] 
args) {
	    new SubTest().print();
	  }
	  void print() {
	    System.out.println(s + " " + 
super.s);
	  }
	 }
	 ---------------------------------------
	 --------------output-------------------
	 java.lang.NoSuchMethodError: main
	 Exception in thread "main" 
	 ---------------------------------------
Comment 1 Petr Hrebejk 2004-08-30 14:35:00 UTC
Well, the SubText in the code is not an innerclass. 

Anyway will attach and source with innerclass and second class in
source setting any of them as main does not work. The IDE always means
the project has no main class set and shows the main class selection
dialog.
Comment 2 Petr Hrebejk 2004-08-30 14:36:06 UTC
Created attachment 17224 [details]
Sample source code
Comment 3 pzgyuanf 2004-08-31 07:55:55 UTC
your are right!
but can not set the Main Class other than javaapplication1.Main(your
attachment Sample source code) in the project properties dialog.
meanwhile, when I renamed the inner class Test to Test1, the project
structrue windows not changed(still Test)
Comment 4 pzgyuanf 2004-08-31 08:09:26 UTC
still try this(simply):
package test;
public class Test {
    
}

class Test2 {
    public static void main(String[] args) {
            System.out.println("Test2");
        }
}

when set the main class to test.Test2, The IDE always means
the project has no main class set and shows the main class selection
dialog.

Comment 5 Martin Matula 2004-08-31 09:46:02 UTC
You cannot set a non-public class to be main.
Comment 6 Pavel Flaska 2004-10-07 13:59:17 UTC
Main method in inner class cannot be run. (You can try it from command
line.)
In second top-level class, you can declare main method, which can be
run. IDE works only with public class in a file and does not resolve
main() method in other classes in the same file.

Comment 7 Jesse Glick 2004-10-29 14:37:51 UTC
So, invalid I presume?