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.
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" ---------------------------------------
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.
Created attachment 17224 [details] Sample source code
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)
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.
You cannot set a non-public class to be main.
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.
So, invalid I presume?