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.
|Summary:||Definition of project main class does not allow setting class not in source|
|Component:||Project||Assignee:||Jiri Rechtacek <jrechtacek>|
|Severity:||blocker||CC:||bstan, jglick, johnjullion, tzezula|
|Issue Type:||DEFECT||Exception Reporter:|
|Bug Depends on:|
|Attachments:||a possible patch|
Description raulfonseca 2004-06-03 12:14:24 UTC
When I try to run a project, netbeans alerts me to the fact that I do not have a project main class set. It then presents me a list of classes that have a main method it has found...However the main class I need is not included. I think that is because netbeans only searches for classes with main methods that are in the source tree. However my application must be lauched within a jar package I have included in the project libraries. Shouldn't Netbeans search for main classes in the configured external libraries too ? thank you.
Comment 1 Jesse Glick 2004-06-03 22:29:48 UTC
Making P3, since there is no workaround - the IDE really blocks you from running the project even if you know better.
Comment 2 Jiri Rechtacek 2004-06-04 15:45:40 UTC
Should be fixed in promoD, MainClassChooser should consult the existence of main classes with java sources repository (current state is a little temporary).
Comment 3 herkules 2004-07-22 09:16:01 UTC
Even if the main class does not appear in the list of possible candidates, at least setting it manually should be accepted. In my case, the main class is set correctly in the 'Project Properties' dialog, but NB still refuses to run the project claiming the main class is not set. Browsing for the main class in larger projects isn't an option anyway, bc. it takes very long.
Comment 4 Milan Kubec 2004-07-22 09:21:46 UTC
To Joerg: What build of IDE do you have that doesn't respect project main class setting? Please could you provide steps to reroduce? Thanks
Comment 5 herkules 2004-07-22 09:24:47 UTC
To Milan Kubec: 200407201800
Comment 6 herkules 2004-07-22 09:37:01 UTC
To Milan Kubec: I have 2 projects, lets call them proj1 and proj2, where proj2 depends on proj1, but proj1 contains the main class (proj1 is kind of a framework). For proj2, I open the 'Project Properties' dialog, ->'Running Project' and edit the 'Main Class' textfield to the main class from proj1. Press 'OK'. When I now want to run proj2, the MainClassChooser pops up saying 'proj2 project doesnt have a main class set'. BTW, when cancelling that, NB often (always?) freezes with 100% CPU load.
Comment 7 Milan Kubec 2004-07-22 14:54:20 UTC
Interesting usecase - having main class in dependent project, but it really seems it doesn't work. Although debugging works OK and correct main class is executed. Developers, is it supposed to be supported to execute main class from dependent project? If so, then P2 is more appropriate to me since the feature doesn't work. I cannot reproduce the 100% load after canceling the dialog.
Comment 8 herkules 2004-07-23 07:02:36 UTC
This must be the case in any project that is framework-like. What about NB itself? When developing a module, that module depends on the NB framework, but does not contain an own main-class? In my case, where depending and master project are developed together, having a multi-source-tree project would be highly advantagious. Having one project and pulling together the sources it needs (like in good'ol NB3.6 times). Otherwise I'd need to maintain a vast amount of projects that I e.g. cannot class-browse in one view. But I think this is a topic in other issues??
Comment 9 herkules 2004-07-23 10:05:02 UTC
Concerning 100% load: Isn't it a background thread gathering all main classes? Is it stopped when 'Cancel' is pressed?
Comment 10 Milan Kubec 2004-07-23 10:20:41 UTC
Maybe that's the problem, ... but probably I don't have such a huge project because I cannot reproduce it.
Comment 11 Jesse Glick 2004-08-10 04:58:13 UTC
*** Issue 46490 has been marked as a duplicate of this issue. ***
Comment 12 Jiri Rechtacek 2004-08-31 15:00:29 UTC
After bugfix #47481 there is a possibility to set a class from libraries as main class and run project with it. But still there is no possible to select these classes by MainClass chooser.
Comment 13 Jiri Rechtacek 2004-09-05 11:14:25 UTC
The sources are not looked through current project's libraries, eventual main classes are not exposed in MainClassChooser. An user is offered to set a main class from library manually, the Run action provider allow to run it. I think it's enough to support this use case for now. I'm going to change to enhancement to track it as possibility for new releases. Thanks for feedback.
Comment 14 Jesse Glick 2004-10-27 20:41:22 UTC
*** Issue 49739 has been marked as a duplicate of this issue. ***
Comment 15 Jesse Glick 2004-10-29 14:36:50 UTC
Any progress on this? Just saw a lengthy blog by someone who got bitten by this in beta 2...
Comment 16 Tomas Zezula 2004-11-01 09:54:28 UTC
It does not work as Jirka stated. User can type the name of main class by hand, but the J2SEActionProvider verifies that the main class is valid. I tried to force ClassIndex to use ClassPath.EXECUTE rather then MergedClassPath (which is used now), but it didn't work (javacore does not care about runtime classpath). The fix of it is non trivial, I needed to use classfile module to read the file to check for main method. But Friday evening was not the right time to commit this change, I wax not sure if we want to add this dependency and do it in this way.
Comment 17 Jesse Glick 2004-11-01 21:18:42 UTC
So this is a bug, not an enhancement, since Jirka's comments from 2004-09-05 are not true.
Comment 18 Jiri Rechtacek 2004-11-02 11:00:18 UTC
My comment that it's works is valid partially. It works only if the library, which is part of Running classpath, is Netbeans project. I'm trying find any patch how to check the 'mainclass' property against ClassPath.EXECUTE.
Comment 19 Jiri Rechtacek 2004-11-02 14:34:21 UTC
Created attachment 18671 [details] a possible patch
Comment 20 Jiri Rechtacek 2004-11-02 14:42:41 UTC
It could be patched, the "main.class" property check can be check both in sources and in EXECUTE classpath. (anyway the check against sources is useless because is a subset of EXECUTE classpath). The main classes in libraries are not exposed in MainClassChooser but can be set manually and executed as well as call run target from command line. Note: patch contains a bugfix of clazz module which should be integrated before integration this patch.
Comment 21 Jiri Rechtacek 2004-11-04 12:19:50 UTC
The problem in clazz module has been fixed (issue 51113), I'm ready to integrate attached patch in main trunk.
Comment 22 Jiri Rechtacek 2004-11-05 11:13:49 UTC
fixed in java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEActionProvider.java; /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEActionProvider.java,v <-- J2SEActionProvider.java new revision: 1.30; previous revision: 1.29 done