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 178257 - I am unable to "run file" on a file that does have a valid main method
Summary: I am unable to "run file" on a file that does have a valid main method
Status: RESOLVED DUPLICATE of bug 242261
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 8.0
Hardware: PC All
: P3 normal with 4 votes (vote)
Assignee: Tomas Zezula
Depends on:
Reported: 2009-12-07 10:03 UTC by slreynolds
Modified: 2017-04-09 05:09 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:

screen shot showing that the file MudLogViewerApp is not runnable (232.58 KB, image/png)
2009-12-07 10:03 UTC, slreynolds
re-occurance of the problem (159.16 KB, image/png)
2009-12-09 12:10 UTC, slreynolds
screen shot of re-occurrence with LasParserExample (234.26 KB, image/png)
2009-12-10 12:46 UTC, slreynolds
messages.log of unsuccessfull attempt to run file (52.58 KB, application/octet-stream)
2011-04-12 13:14 UTC, mklaehn

Note You need to log in before you can comment on or make changes to this bug.
Description slreynolds 2009-12-07 10:03:09 UTC
Created attachment 92234 [details]
screen shot showing that the file MudLogViewerApp is not runnable

I am unable to "run file" on a file ( that does have a valid main method. The "run file" menu options are greyed out, and in the project window, the file is lacking the icon badge denoting that it has a main method.

I've attached a screen shot that shows the state of NetBeans when I saw this problem. Just previously to this I had done a cvs update, and then a "clean build". You can see the build status completed without any errors in the lower right window.

I have about 150 java files that are supposed to be runnable, I cannot create seperate run configurations for each. I depend on being able to use the "run file" feature a lot.

I was using NetBeans 6.8 RC 1 when I saw this issue.
Comment 1 Peter Pis 2009-12-08 08:10:13 UTC
Have you tried to invoke it directly from editor tab area as popup menu action?
Comment 2 Ivan Sidorkin 2009-12-08 08:42:29 UTC
works fine with latest 6.8 build on Linux, Mac OS, WinXP using Java Applcation

  slreynolds, what kind of project do you use?

it is very strange that Run Project menu item disabled. it should be enabled for all java projects.
moreover, Run File menu enabled even for java classes without main method
Comment 3 slreynolds 2009-12-08 10:55:57 UTC
I have a plain Java SE project (a Swing desktop application). In NB terms it is a "Java Project with Existing Sources".

The pop up menu from the edit tab area showed the same behavior.

This behavior appears to be intermittent -- when I restart NB, I cannot reproduce this problem anymore.
Comment 4 Tomas Zezula 2009-12-08 11:08:31 UTC
One more question (sorry).
Is the source root under the project folder? Or is it located in the different folder?
Comment 5 slreynolds 2009-12-08 11:20:09 UTC
The source root for the file in question is


The NB project is at


I'm not using any symbolic links. The project has other source roots which are

Comment 6 slreynolds 2009-12-09 12:10:24 UTC
Created attachment 92360 [details]
re-occurance of the problem

It happened again today with NB 6.8 RC2.
Comment 7 slreynolds 2009-12-09 12:32:14 UTC
Sorry, I guess that my immediately previous attachment and comment is wrong in an important way. The file I was trying to run today,, is in a project that is a NetBeans module. Trying to "run file" in a NetBeans module probably doesn't make any sense, and NetBeans is preventing me from doing something stupid (oops too late).

Please ignore my immediately previous attachment and comment from 2009-12-09 12:10:24.
Comment 8 slreynolds 2009-12-10 12:46:10 UTC
Created attachment 92393 [details]
screen shot of re-occurrence with LasParserExample

re-occurrence of the problem (no really this time).

After this re-occurrence, I exited NB and then restarted it. I was then able to run the file.
Comment 9 Tomas Zezula 2011-04-06 14:25:09 UTC
I am not able to reproduce, seems to work fine in dev.
I've added logging into the dev build. If you can reproduce it with dev build please run it with command line option and attach the log.

jet-main acc9532589d0
Comment 10 Quality Engineering 2011-04-07 08:46:39 UTC
Integrated into 'main-golden', will be available in build *201104070400* on (upload may still be in progress)
User: Tomas Zezula <>
Log: #178257:I am unable to "run file" on a file that does have a valid main method
Comment 11 slreynolds 2011-04-11 20:11:21 UTC
I downloaded NB dev 201104070400. I do not see this problem now; I think it has been a long time since I've seen it.

I've enabled the logging option that you requested, and if I can reproduce this issue, I'll upload the generated log file.
Comment 12 mklaehn 2011-04-12 13:12:02 UTC
For me this works with the project types
    Java Application and
    Java Class Library

But if I
1) create a Platform Application,
2) add a module to it,
4) add a Java class to that module and
4) insert a main method (using code template psvm)
i can not run that file. Not via the menubar or the contextmenu.

Changing the package the java class is in to public in the modules API versioning does not change this behavior.

I'll attach the messages.log file shortly.
Comment 13 mklaehn 2011-04-12 13:14:47 UTC
Created attachment 107685 [details]
messages.log of unsuccessfull attempt to run file

in that file i tried to run a class from within an Module, Java Application and Java Classfile project.

Java Application and Java Classfile projects with success.
Module Project without success.
Comment 14 Tomas Zezula 2011-04-12 13:50:21 UTC
>create a Platform Application
Not j2se project. Please report on apisupport/project.
Comment 15 Zom-B 2014-04-18 07:03:18 UTC
I had the same condition in NetBeans 8.0 with a stand-alone project. Couldn't run no matter what, even though I ran it tons of times in the past.

After restarting NetBeans, I could run again like normal. So I guess this really is a (rather unproduceable) bug.
Comment 16 reubeniv 2014-05-14 11:35:51 UTC

Just to add I encountered the bug just now in Netbeans 8.0. Came here, restarted Netbeans and it worked fine. Not a clue how it happened. 

Netbeans had been open for a few days. I had created a project with multiple classes in the same folder to make a simple binary tree, then created a new project with a single class with multiple functions outside of the Main and tried to run and couldn't. I could only run the previous program using shift+F11. Any new projects wouldn't run either.

I can't seem to reproduce it.

I tried running the tree file again then running the last one, bug didn't happen.
I tried running the tree file then building a new program identical to the one I had open when the bug happened and the bug didn't happen.

I'm sorry I can't think how else to try.
Comment 17 ArxSicra 2014-05-25 20:48:24 UTC
Hi everyone!

Don't know if this can help something, but I have had the same problem, and it has persisted even restarting NB 8.0...

I've solved it just changing the project folder name in Windows explorer (this has been enough for me)...

It isn't the first time it happened to me. 

Hope this help to find the problem.
Comment 18 User888 2014-06-08 13:38:32 UTC
I use NetBeans 8.0 every day and about every 3rd day I run into this bug. I can overcome it by terminating NetBeans and starting it again (sometimes I have to repeat more than once). I have no idea what causes this bug but it happens again and again.
Comment 19 lagrangepoint 2014-06-20 08:40:15 UTC
I had exactly this. Three restarts of the IDE sorted it.
Comment 20 epnomis 2014-07-31 07:59:34 UTC

*** This bug has been marked as a duplicate of bug 242261 ***
Comment 21 sagar7777 2017-04-09 05:09:59 UTC
Comment on attachment 92234 [details]
screen shot showing that the file MudLogViewerApp is not runnable

the same problem occurs in my web application how can  I solve this type of error.