NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Netbeans used to work - now the files are crossing and other problems

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
Marian



Joined: 06 Jan 2010
Posts: 7

PostPosted: Sun Jan 10, 2010 12:00 pm    Post subject: Netbeans used to work - now the files are crossing and other problems Reply with quote

Hi -

I really hope I can get some serious help here Very Happy - A month ago I took a quick JAVA course - I used Netbeans 6.7 for writng many programs - I always used File -> New Project and then File-> New File (for setting the main class). It worked perfectly, I could even jumped back and forth between programs.

Now here's where the trouble came in...
1- Suddenly when I tried to Run a program I got a message that I had no Main Class

2- Even if I tried to run one of my old programs that I knew had worked, I also got a message that I had No Main Class

3- Now things got a little better... Suddenly it must be recognizing some main class because I can actually get some output, but what is happening is that after I run my first program, no matter what I opened and had on my screen for another program (old or new) when I run, I get the results of the first program - The little tab on top of the output screen will even say the name of that first program which it is now running (though I have no idea why)

I am wasting days, getting no work done, because suddenly Netbeans is playing tricks on me.

Can you help???

thanks Smile
Marian
Back to top
Mark Wade
Posted via mailing list.





PostPosted: Sun Jan 10, 2010 10:49 pm    Post subject: Netbeans used to work - now the files are crossing and other problems Reply with quote

Hello Marian,

I just replied to, apparently, a previous post of yours, here and to
you directly. So, good, you seem to be making progress.

When you say:
Quote:
I always used File -> New Project and then File-> New File (for
setting the main class). It worked perfectly, I could even jumped
back and forth between programs.

Do you mean you had many source files with a main method in the same
Project or many projects with a single source file with a main
method? Either way is perfectly okay.

How do you run a program? If you select "Run" from the menu or click
the "Run" button you have to have set the project your application is
in as the default project and also set the file to run in that
project's preferences.

If you right-click on the project node and select "Run" you have to
have the file to run set in that project preferences.

Any file with a main method can be run by right-clicking on it and
selecting "Run" which by-passes any run preferences that are set.

On Jan 10, 2010, at 7:00 AM, Marian wrote:

Quote:
Hi -

I really hope I can get some serious help here Very Happy - A month ago I
took a quick JAVA course - I used Netbeans 6.7 for writng many
programs - I always used File -> New Project and then File-> New
File (for setting the main class). It worked perfectly, I could even
jumped back and forth between programs.

Now here's where the trouble came in...
1- Suddenly when I tried to Run a program I got a message that I had
no Main Class

2- Even if I tried to run one of my old programs that I knew had
worked, I also got a message that I had No Main Class

3- Now things got a little better... Suddenly it must be recognizing
some main class because I can actually get some output, but what is
happening is that after I run my first program, no matter what I
opened and had on my screen for another program (old or new) when I
run, I get the results of the first program - The little tab on top
of the output screen will even say the name of that first program
which it is now running (though I have no idea why)

I am wasting days, getting no work done, because suddenly Netbeans
is playing tricks on me.

Can you help???

thanks Smile
Marian





Mark Wade
address-removed
Back to top
Marian



Joined: 06 Jan 2010
Posts: 7

PostPosted: Mon Jan 11, 2010 8:35 am    Post subject: Reply with quote

Thank-you for all the help. Using the tree of projects and then right clicking -> run on the actual file does work so I am very relieved (and very grateful) that I can go on like that but overall I am still stuck that I can't simply choose the "run" icon (the green arrow) to run my file (it used to work so nicely). When I click on the icon it automatically chooses to run the file I was in before (possibly, the one I was in before was actually new - I'll have to check that),

I have on top tabs for the last few programs I had run (not in the same project, different projects) and I know I used to be able to choose a different tab (usually for reference I did this - to learn from things I did in the past) and then if I pressed the green icon it would run whatever program I had just brought up on my screen.

It's now deciding one project/file is the default and that's what the green arrow does every time.

Anyway, like I said, it's a little annoying but at least I can continue by using this mehod of right clicking on the actual file in the project and then choosing run

Thanks

PS - if you can give advice for handling the green button/default problem, I'd appreciate that - thanks
Back to top
Mark Wade
Posted via mailing list.





PostPosted: Tue Jan 12, 2010 2:23 am    Post subject: Netbeans used to work - now the files are crossing and other problems Reply with quote

I think I'm getting a handle on this...

Quote:
I have on top tabs for the last few programs I had run (not in the
same project, different projects)

When you create a new project in a "Project Group" ( (none) is still a
group) the new project defaults to the "Main Project" which is the
project whose "Main Class" is executed when you choose the green right-
facing run icon or "Run Main Project" from the "Run" menu. So, each
time you created a new project, that new project became the"Main
Project" by default and pressing the run icon executed what had
defaulted to the "Main Class". Now, NetBeans will generate by default
a "Main.class" ( at least for a Java Application it will) but you can
choose to generate that class or not and set any class with a public
static void main(String args[]) method as the "Main Class". So, the
"Main Class" is not necessarily "Main" and quite possibly needs to be
set in the project properties.

It seems to me you created new projects for each app and used the
default options. When you rearranged the directory structure you broke
NetBeans' references to the projects' main classes.

In a "Project Group", be it one you have created, or the lack of one,
(none), when you have multiple projects open, only one can be the
"Main Project" who's "Main Class" will be executed when you press the
"Run Main Project (F6)" icon/button. You can set the main project by
right-clicking on the project node in the project tree and selecting
"Set as Main Project" in the menu. You may also have to set that
project's main class.

On Jan 11, 2010, at 3:35 AM, Marian wrote:

Quote:
Thank-you for all the help. Using the tree of projects and then
right clicking -> run on the actual file does work so I am very
relieved (and very grateful) that I can go on like that but overall
I am still stuck that I can't simply choose the "run" icon (the
green arrow) to run my file (it used to work so nicely). When I
click on the icon it automatically chooses to run the file I was in
before (possibly, the one I was in before was actually new - I'll
have to check that),

I have on top tabs for the last few programs I had run (not in the
same project, different projects) and I know I used to be able to
choose a different tab (usually for reference I did this - to learn
from things I did in the past) and then if I pressed the green icon
it would run whatever program I had just brought up on my screen.

It's now deciding one project/file is the default and that's what
the green arrow does every time.

Anyway, like I said, it's a little annoying but at least I can
continue by using this mehod of right clicking on the actual file in
the project and then choosing run

Thanks

PS - if you can give advice for handling the green button/default
problem, I'd appreciate that - thanks





Mark Wade
address-removed
Back to top
Marian



Joined: 06 Jan 2010
Posts: 7

PostPosted: Tue Jan 12, 2010 7:41 am    Post subject: Reply with quote

PERFECT!! - I just started a long reply to you with lots of questions but as I typed I checked all you said and "thought". Then I realized what I was missing was Project Groups! - If I wanted to keep a second folder of projects I need a second project group. (before my tree showed all the projects regardless of which folder they were in, I had no group).

Thanks alot Very Happy Very Happy
Marian

(Now all I have to figure out is constructors, extends, static and root bases - but that's for a different forum (any suggestion of a good one?))
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo