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 | ||
---|---|---|---|
Product: | java | Reporter: | raulfonseca <raulfonseca> |
Component: | Project | Assignee: | Jiri Rechtacek <jrechtacek> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | bstan, jglick, johnjullion, tzezula |
Priority: | P3 | ||
Version: | 4.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | |||
Bug Blocks: | 41537 | ||
Attachments: | a possible patch |
Description
raulfonseca
2004-06-03 12:14:24 UTC
Making P3, since there is no workaround - the IDE really blocks you from running the project even if you know better. Should be fixed in promoD, MainClassChooser should consult the existence of main classes with java sources repository (current state is a little temporary). 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. 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 To Milan Kubec: 200407201800 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. 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. 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?? Concerning 100% load: Isn't it a background thread gathering all main classes? Is it stopped when 'Cancel' is pressed? Maybe that's the problem, ... but probably I don't have such a huge project because I cannot reproduce it. *** Issue 46490 has been marked as a duplicate of this issue. *** 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. 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. *** Issue 49739 has been marked as a duplicate of this issue. *** Any progress on this? Just saw a lengthy blog by someone who got bitten by this in beta 2... 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. So this is a bug, not an enhancement, since Jirka's comments from 2004-09-05 are not true. 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. Created attachment 18671 [details]
a possible patch
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. The problem in clazz module has been fixed (issue 51113), I'm ready to integrate attached patch in main trunk. 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 |