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 161545 - No Main Class Found"
Summary: No Main Class Found"
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: Other Linux
: P3 blocker with 5 votes (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-31 05:15 UTC by lapchinj
Modified: 2012-10-26 16:07 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
comlete project and IDE log (249.83 KB, text/plain)
2009-04-12 04:08 UTC, lapchinj
Details
comlete project and IDE log used with netbeans 6.7m2 (249.83 KB, text/plain)
2009-04-12 04:26 UTC, lapchinj
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lapchinj 2009-03-31 05:15:19 UTC
I'm running:
OS: Linux
OS Version: openSUSE 10.3 (X86-64)
Kernel Level: 2.6.22.5-31-default

Product Version: NetBeans IDE Dev (Build 200902231810)
Java: 1.6.0_12; Java HotSpot(TM) 64-Bit Server VM 11.2-b01
System: Linux version 2.6.22.5-31-default running on Dual Processor amd64; UTF-8; en_US (nb)
Userdir: /home/yel/.netbeans/6.7m2

I upgraded a previous version of netbeans to netbeans-6.5.1-ml-java-linux.sh. After installing 6.5.1 I could not run my
apps. A clean & recompile would be successful but upon running the app I would get "No Main Class Found". I created
numerous variations of a Java Desktop Application Project all compiling successfully but would not run. I looked and
tried numerous fixes and suggestions by fellow developers on the forums but could not get Java Desktop apps to run. I
downloaded and reinstalled 6.5.1 numerous times (at least 5) with the same results - would not run.
I decided to go to the latest milestone build. I downloaded netbeans-6.7_m2-java-linux.sh and the same project apps that
ran prior to 6.5.1, the project apps created with 6.5.1 but did not ran when I did a clean & recompile on 6.7 m2. All
project apps are now running.
Comment 1 Milos Kleint 2009-03-31 06:41:03 UTC
reinstalling the ide might not work if you have something broken in the project build script or metadata..

reassigning to j2se projects (as you said it affects the desktop application)
Comment 2 Jan Jancura 2009-04-09 13:02:19 UTC
I can not reproduce this issue.
I have created Java Desktop Application from main menu > File > New Project - Java / Java Desktop Application.
And than I have selected DesktopApplication1 node in Projects View and pressed "Run" action. Everything is OK.

Can you attach:
1) your exact steps how to reproduce this issue
2) some sample project
3) your IDE log? see your userdir/var/log/messages.log
Thanks.
Comment 3 lapchinj 2009-04-12 04:08:55 UTC
Created attachment 79939 [details]
comlete project and IDE log
Comment 4 lapchinj 2009-04-12 04:26:29 UTC
Created attachment 79940 [details]
comlete project and IDE log used with netbeans 6.7m2
Comment 5 lapchinj 2009-04-12 04:49:16 UTC
I see that 'Target milestone' is set to 6.7 is this correct?
I reinstalled netbeans-6.5.1-ml-java-linux.sh which I downloaded this evening. I still have
netbeans-6.7_m2-java-linux.sh installed in /usr/local in a separate folder.
I sent two tarballs (I lost my comments though) the first tarball called Issue161545-b.tar.gz and contains a project
snapshot just as it was after running through the netbeans 6.5.1 IDE. The IDE log is included in the project's root.
This project was created with netbeans 6.5.1. None of the generated code was edited at all. just create project, clean
compile and run. When run I received the error 'no main class found'. 
The second tarball called Issue161545-b_6.7m2.tar.gz also contains both a snapshot of the complete project after it was
run through netbeans 6.7m2 and the IDE log in the project's root. I compiled and ran the same project with netbeans
6.7m2 and it ran fine with no errors.
Both tarballs contain the same directory structure and names and one will overwrite the other.
Comment 6 Peter Pis 2009-09-03 08:22:54 UTC
Requested info attached. Removing INCOMPLETE.
Comment 7 bouzarkouna 2010-02-08 11:09:53 UTC
I'm an intensive user of netbeansIDE 6.5. and for many times, I was in front of this problem " No Main Class Found" where you can build or run your project. I'm sure that there's no bug in the source code.

I can't reprduce this problem. But I know the solution to this problem and this might inspirate you on the origin of the bug in netbeans.

Actually, to work, you must use the "touch" command for code sources (change the dates of sources). In this case, it works. I guess that the bug happens then if source files are older than other files (I don't have any idea what it can be) ...

Thanks.
Zyed
Comment 8 Tomas Zezula 2010-02-08 11:29:07 UTC
Yes,
it's caused by inconsistency in the IDE internal caches. By modifying the file you force the IDE to reindex it and to fix the caches.
Comment 9 Nomade 2012-03-06 18:27:14 UTC
OS version: Mac OS 10.7.3
NetBeans version: 7.1.1
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)

Using the AnagramGame sample Java application provided by NetBeans:

'Clean & Build Main Project (SHIFT-F11)' command is successful but when trying to 'Run the main project (F6)' I get error:
' com.toy.anagrams.ui.Anagrams class wasn't found in AnagramGame project.' 
and "No Main Classes Found" in 'Select the main class' dialog box below the message.

But this class does exist and if I go directly to file Anagrams.java and right-click and 'Run File (SHIFT-F6)' the file runs fine.

I have tried to create very simple project with one class in default package and I get same error. NetBeans used to work fine for months before this problem appeared.

Command 'Test Project (CTRL-F6)' runs fine, only 'Run Main Project' and 'Debug Main Project' commands produce error dialog 'class wasn't found' as described above.
Comment 10 Nomade 2012-03-06 18:30:52 UTC
Additions to my comment above:

- I did try to use touch to change last modified date of source files as suggested above, error still appears
- I did remove the user/.netbeans directory, error still appears
Comment 11 Tomas Danek 2012-10-26 11:54:16 UTC
not able to reproduce with attached project, now with steps to reproduce in 

Product Version: NetBeans IDE Dev (Build 201210220002)
Java: 1.7.0_10-ea; Java HotSpot(TM) 64-Bit Server VM 23.6-b04
System: Mac OS X version 10.8.2 running on x86_64; US-ASCII; en_US (nb)
User directory: /Users/tomas/Library/Application Support/NetBeans/dev
Cache directory: /Users/tomas/Library/Caches/NetBeans/dev

...can you please try to reproduce in latest NetBeans (7.2.1 or 7.3 Beta) and reopen if this still happens? Thanks in advance!
Comment 12 Nomade 2012-10-26 12:58:37 UTC
Installed NetBeans 7.3beta and error did not happen. Hopefully bug has been definitely resolved! Thanks!