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 242261

Summary: Run File menu is disabled eventhough main() method is available in a class
Product: projects Reporter: adithyank
Component: Generic Projects UIAssignee: Tomas Stupka <tstupka>
Status: NEW ---    
Severity: normal CC: atomsymbol, cpholt, cybersoft, Epigon, henri127, mmirilovic, slreynolds, tomas.langer, zlob.jc
Priority: P3    
Version: 8.0   
Hardware: PC   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: IDE log
screenshot showing runfile toolbar button is disabled eventhough the class contans main() method
screenshot showing runfile toolbar button is enabled after nb restart
file without main method shows ability to run file-level commands
file with main method not able to run file level commands

Description adithyank 2014-02-24 08:00:38 UTC
Product Version = NetBeans IDE Dev (Build 201402140001)
Operating System = Linux version 2.6.32-431.5.1.el6.i686 running on i386
Java; VM; Vendor = 1.8.0-ea
Runtime = Java HotSpot(TM) Client VM 25.0-b63

Run File menu is disabled eventhough main() method is available in a class. After I observer this, If i restart the nb ide, the button becomes enabled. Both the screenshots are attached
Comment 1 adithyank 2014-02-24 08:00:42 UTC
Created attachment 145524 [details]
IDE log
Comment 2 adithyank 2014-02-24 08:04:48 UTC
Created attachment 145525 [details]
screenshot showing runfile toolbar button is disabled eventhough the class contans main() method
Comment 3 adithyank 2014-02-24 08:04:52 UTC
Created attachment 145526 [details]
screenshot showing runfile toolbar button is enabled after nb restart
Comment 4 Jiri Kovalsky 2014-03-04 16:30:08 UTC
Are you sure that "TATA-OTNMS" package node in the Favorites view didn't have focus? In such a case the "Run File" button should be really disabled.
Comment 5 adithyank 2014-03-05 07:43:06 UTC
I am very sure that I clicked the editor and saw that the run file button is disabled.

Also, it is evident from the screenshot that the background color of the editor tab title is white. It is the behavior of the GTK L&F that currently focussed tab's background is white. I confirmed this again now with netbeans IDE.
Comment 6 kahatlen 2014-03-12 11:45:54 UTC
I also experienced this after upgrading from 7.4 to 8. Both Run File (Shift-F6) and Compile File (F9) were grayed out in the Run menu. After a restart, they both were working again.

Product Version: NetBeans IDE 8.0 (Build 201403101706)
Java: 1.8.0; Java HotSpot(TM) 64-Bit Server VM 25.0-b70
Runtime: Java(TM) SE Runtime Environment 1.8.0-b132
System: Linux version 3.2.0-4-amd64 running on amd64; UTF-8; en_US (nb)
Comment 7 Epigon 2014-03-14 15:46:39 UTC
Created attachment 146026 [details]
file without main method shows ability to run file-level commands
Comment 8 Epigon 2014-03-14 15:47:16 UTC
Created attachment 146027 [details]
file with main method not able to run file level commands
Comment 9 Epigon 2014-03-14 15:51:03 UTC
I have had this problem with a few more details.

I've attached two more screenshots showing the issues. Not only does the runnable file not allow file level commands such as build, run, or debug but also the non-runnable file shows that it can run or debug. Of course when trying to actually do so on the non-runnable file it fails (as expected).

Restarting NetBeans and my computer did not resolve this issue. The only way I can run files is to set them as the main class for my project.

Product Version: NetBeans IDE 8.0 RC1 (Build 201402242200)
Java: 1.8.0; Java HotSpot(TM) 64-Bit Server VM 25.0-b70
Runtime: Java(TM) SE Runtime Environment 1.8.0-b132
System: Windows 8 version 6.2 running on amd64; Cp1252; en_US (nb)
Comment 10 wobster 2014-07-22 00:41:04 UTC
This problem showed up for me in a JFrame form with a main method. I'm using build 201403101706.
Comment 11 Tomas Stupka 2014-07-22 15:08:40 UTC
wan't able to reproduce with current build 20140722 - neither on a simple java file, nor a jframe form

will add some logging, once that is available in a daily build, please try to reproduce and attach your messages.log to the issue.
Comment 12 wobster 2014-07-22 15:12:20 UTC
Is there some information I can provide in the current build to assist in debugging?
Comment 13 Tomas Stupka 2014-07-22 15:15:08 UTC
more logging core-main #3f4cabdc8d05

to enabled the loggin run NetBeans with -J-Dorg.netbeans.modules.project.ui.actions.FileAction.level=400
Comment 14 Tomas Stupka 2014-07-22 15:16:52 UTC
> Is there some information I can provide in the current build to assist in debugging?
a message should be generated into this issue once the commit above made it into daily builds. 
Run then NB with the mentioned switch, reproduce and attach messages.log

thanks
Comment 15 Quality Engineering 2014-07-23 02:07:33 UTC
Integrated into 'main-silver', will be available in build *201407230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/3f4cabdc8d05
User: Tomas Stupka <tstupka@netbeans.org>
Log: issue #242261 - Run File menu is disabled eventhough main() method is available in a class
added logging
Comment 16 epnomis 2014-07-31 07:59:34 UTC
*** Bug 178257 has been marked as a duplicate of this bug. ***
Comment 17 tez 2014-08-19 16:31:42 UTC
I applied the above fix to the current version of netbeans by integrating the compiled FileAction class & anonymous classes (taken from nightly-201408160001) into the org-netbeans-modules-projectui.jar of the current version. This should have worked & for the most part it seems that if the menu option was active it stayed that way whereas before it might become deactivated (grayed out) after some action was taken e.g. a "clean and compile". But... Today as I launched netbeans for the first time after booting up, and checked the menu option as it performed a background scan it was grayed out and stayed that way?? Any thoughts?
Is there also some other issue that needs to be addressed?
Comment 18 Tomas Stupka 2014-09-12 11:50:12 UTC
> I applied the above fix to the current version of netbeans ...
it wasn't a fix, just added some logging to the involved code

please reproduce in netbeans and then attach your messages.log file to the issue

thanks
Comment 19 cpholt 2014-11-26 15:32:45 UTC
I experience this problem daily under 8.0.1.  I have a Project Group with 18 projects that I regularly work in.  Under 8.0.1, at least 50% of the time, one or more of them (not always the same ones!) will fail to enable the run/debug/etc buttons.  The only fix is to restart NB.  Close/Open the project makes no difference.

As per the suggestion here, I installed the nightly dev build a few days ago and added the debug log settings.  And of course the problem won't reproduce.  (OS Ubuntu Linux, 1.7.0_51 OpenJDK).

I tried to compare activated plugins between the 8.0.1 and dev setups, but there were many that would not install under the nightly build.  The C++ plugin and at least 1 other one, had this error:

"The plugin Common Test Runner API is requested in version >= 1.26 (release version 1) but only 2.1 (of release version different from 1) was found."

While that's probably not related to the root cause of this problem, I mention it just in case.

Are there any other debug logs that we can activate to help diagnose this under 8.0.1?
Comment 20 mtamassia 2015-03-20 14:41:42 UTC
I have this issue at least 2 times a week and restarting the IDE fixes it.

It would be great to have this addressed/taken care somehow.

My details.
Product Version: NetBeans IDE 8.0.2 (Build 201411181905)
Updates: NetBeans IDE is updated to version NetBeans 8.0.2 Patch 1
Java: 1.8.0_11; Java HotSpot(TM) 64-Bit Server VM 25.11-b03
Runtime: Java(TM) SE Runtime Environment 1.8.0_11-b12
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 21 Tomas Stupka 2015-06-03 14:25:24 UTC
*** Bug 250378 has been marked as a duplicate of this bug. ***
Comment 22 Tomas Stupka 2015-06-03 14:25:41 UTC
*** Bug 247527 has been marked as a duplicate of this bug. ***
Comment 23 Tomas Stupka 2015-06-03 14:26:37 UTC
*** Bug 251268 has been marked as a duplicate of this bug. ***
Comment 24 Tomas Stupka 2015-06-03 14:36:03 UTC
*** Bug 247706 has been marked as a duplicate of this bug. ***
Comment 25 Tomas Stupka 2015-09-08 14:29:16 UTC
*** Bug 254102 has been marked as a duplicate of this bug. ***
Comment 26 aljsteiner2 2015-09-19 12:04:48 UTC
NB 8.0.2 running on desktop Windows 10 64bit, JDK 1.8.0_60, with a java application in development now for 5 years.

I ran into this problem, after a power failure, with NB up and all files saved and the application runing.  After I restarted the desktop and restarted NB 8.0.2 I could not get the run button to darken for a Java application project.  I quit and restarted NB 8.0.2: no help.  I changed contents of a file in NB saved and restarted: no help.  The files for my projected are in a Google Drive folder, so that this is shared between 2 machines.  After I quite NB, I selected the documentation.txt file in src, and edited it slightly using wordpad, saved the edited file, exit wordpad, start NB 8.0.2  now I have the run button available.  I have done this twice.
Comment 27 dgradwell 2015-09-24 19:47:34 UTC
I have hit the same problem with NetBeans 8.0.2 on Mac OS X 10.10.5.

Quitting NetBeans and restartiung doesn't help.

Only affects the project I am developing - business critical !

Following along the lines of comment 26 I opened project.properties using textEdit and made a non-change, saved, quit and re-opened NetBeans.  The problem has gone.  Will update if it comes back.
Comment 28 rmiscios 2015-09-28 09:27:26 UTC
hit same problem on:

Product Version: NetBeans IDE 8.0.2 (Build 201411181905)
Updates: NetBeans IDE is updated to version NetBeans 8.0.2 Patch 2
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Linux version 3.2.0-4-amd64 running on amd64; UTF-8; it_IT (nb)
User directory: /home/riccardo/.netbeans/8.0
Cache directory: /home/riccardo/.cache/netbeans/8.0

I have quit Netbeans, deleted the folder ${build.3Ddir}, after this, it worked. Maybe in my case it is related to the presence of a dot in the name of the project directory? 

Best regards.
Comment 29 fsabbir 2015-12-03 15:11:43 UTC
This been's happening on my install of NB too.

NB: 8.0.2
OS: Windows 7 x64
JDK: 1.8.0_60
Comment 30 jslaroch 2015-12-04 17:16:46 UTC
I have observed the same thing happening for the "Test" option.
Restarting the IDE fixes this but it is a major annoyance.
Comment 31 a_paul1 2016-07-04 03:09:59 UTC
Any update on this?
I am have been running into the same issue for quite a while now. Earlier a single restart would fix it. But now even restarting multiple time is not enabling the run or compile file menu items.

This was working fine about an year or so ago.
Comment 32 a_paul1 2016-07-04 03:13:45 UTC
As per comment #26, I closed NB 8.0.2, created an empty doc.txt in project src and restarted NB. Run menu is now enabled. Thanks to #26.
Comment 33 Ralph_Gardner 2016-08-22 17:19:32 UTC
As per comment #26, I closed NB 8.0.2, created an empty doc.txt in project src and restarted NB. Run menu is now enabled. Thanks to #26.