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.
20081028. After making a j2seproject and adding an empty *.groovy class to it, I press F6 - and am greeted with a dialog to select a main class with no entries. If I add a class definition with a public static void main(String[]) method to it, I can select the Groovy class as main, and then delete the method afterwards. This is silly because I can have a Groovy class containing just e.g. ---%<--- println "hello" ---%<--- and run it. Ideally I could set any Groovy class as main if it had any statements in it outside of a class definition.
*** This issue has been marked as a duplicate of 150028 ***
Doesn't really seem to be a duplicate to me. This issue is about the main class chooser. Issue #150028 is about the context menu of *.groovy files. I think they are independent problems.
Yes, I don't see this as a duplicate either. Seems two completely separate issues. In the other the editor needs to know if the file may be run, and if it can run it from the context menu. Here the project support for setting the main class needs to use that same logic to weed out whether or not it can be a main class. Now, running a main method versus running external groovy script...how is that handled? Does the groovy compiler compile those external statements into a main method or something else? If not a main method then those can't be run the same way a main method can by the JVM, well by the Java launcher anyways, the VM can be instructed to run any static method through native library calls, but strictly from the Java project support this needs to be known it seems.
Mea culpa. We should track it as separate issue.
I'm afraid I don't fully understand (or the issue was fixed already). What I'm testing: 1) create Java application without main class 2) create new Groovy class, for example x.NewGroovyClass 3) put public static void main(String[] args){} into it 4) class is offered as main (expected) 5) create new Groovy class, for example x.NewGroovyClass2 6) put println "Hello" outside of the class 7) change the generated class def NewGroovyClass2 to NewGroovyClass2X (otherwise combination of NewGroovyClass2 defined in NewGroovyClass2.groovy file with statements outside of the class is not a valid groovy source) 8) class is offered as main (expected) 9) create new Groovy class, for example x.NewGroovyClass3 10) delete everything in it 11) put println "Hello" to file 12) class is offered as main (expected)
Seems to work in 081120 so I guess it was fixed sometime recently?