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 189270 - Allow selecting main class from different projects than the current one
Summary: Allow selecting main class from different projects than the current one
Status: REOPENED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.0
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Tomas Zezula
URL:
Keywords: UI
Depends on:
Blocks: 166780
  Show dependency tree
 
Reported: 2010-08-06 12:19 UTC by Petr Jiricka
Modified: 2012-03-26 19:02 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2010-08-06 12:19:05 UTC
When you run a Java project and no main class is set, the IDE displays a dialog offering to select from all the available main classes, so you can choose which one to run. It would be useful (especially for library projects), if I was able to also select a main class from a different project. In this case, for a library project I would select a main class from an application that uses this library.

More specifically, consider the following scenario:
1. I have the following projects open in the IDE:
App1, Lib1, App2, Lib2. App1 uses Lib1, and App2 uses Lib2.
2. I work simultaneously on Lib1 and Lib2, and switch between then. Depending on which one I am working on, I'd like to run either App1 or App2, to test my changes.
(but you could imagine many other similar scenarios.)

Currently this requires me to switch the main project all the time back and forth, so I can use the keyboard shortcut for running, debugging, testing, ... If I forget to change the main project, the IDE will run a different project than I intended.

If this enhancement was implemented, it would allow me to have NO main project set, and just work with the current project, and the IDE would behave in an intuitive and predictable way.
Comment 1 Tomas Zezula 2010-08-09 09:11:07 UTC
When selecting a main class in the project, you can also type a class on the project class path. It's not displayed as it's expensive but you can type it by hand.
It may solve your problem with switching the main projects.
Comment 2 Jesse Glick 2010-08-09 20:36:48 UTC
(In reply to comment #1)
> When selecting a main class in the project, you can also type a class on the
> project class path.

Will not help in this case since e.g. app1.Main is not in the CP for lib1.

Can be worked around by overriding in lib1/build.xml:

<target name="run">
  <ant target="run" dir="../app1" inheritall="false"/>
</>
Comment 3 Jesse Glick 2012-01-06 23:06:08 UTC
Really just another use case of bug #166780.

*** This bug has been marked as a duplicate of bug 166780 ***
Comment 4 Jesse Glick 2012-03-20 16:12:19 UTC
No longer a true duplicate. More like option #3 from bug #166780 comment #10.