Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

netbeans how to add main function when adding a java class

Thread view: 
sss - 25 Nov 2006 00:38 GMT
Is there any option to add main method when creating a new class?
I know how to do this with Eclipse, but want to find out this in Netbeans

dd
Wesley Hall - 25 Nov 2006 00:59 GMT
> Is there any option to add main method when creating a new class?
> I know how to do this with Eclipse, but want to find out this in Netbeans
>
> dd

If you open the source code an add a method like this...

public static void main(String[] args)
{
}

...then you can add a main method to any class, using any editor capable
of editing text.
sss - 25 Nov 2006 01:11 GMT
So no optoin to add main function to class with check box?
Maybe stick with Eclipse is the right solution.
sgoo - 25 Nov 2006 01:17 GMT
You can add New File/Folder and choose Java Classes | Java Main Class.
It's not default in the list, but once you have done it once, it will
appear there later. Enough reason for you to convert to Netbeans?
sss - 25 Nov 2006 01:52 GMT
Thanks.

>  Enough reason for you to convert to Netbeans?
humm.... i should say not yet. For a lot of jobs here in Canada,
you need to be familiar with Eclipse. I haven't figured out the reason
yet but I happen to be more familiar with Eclipse. ^^;)
Lew - 30 Nov 2006 07:53 GMT
> For a lot of jobs here in Canada,
> you need to be familiar with Eclipse. I haven't figured out the reason
> yet but I happen to be more familiar with Eclipse. ^^;)

Why the heck do so many managers seem bent on mandating IDEs?  I have worked
in many places where Eclipse was the "standard" IDE for Java, but I cheerfully
went ahead and used Netbeans (and emacs) to do my source development.  Only
when people have absolutely insisted that I must use Eclipse (I still don't
know how they justified that) did I do so, and then only because I like
getting a paycheck.

It's not that I dislike Eclipse very much, only that I prefer Netbeans.  I
have also used JBuilder and WSAD (IBM's WebSphere Application Developer) when
someone else paid for the licenses.

The choice of IDE is, or should be, completely immaterial to the finished
product.  The ultimate deployment environment is command-line, with Ant.  Any
editor from vi on is fine if you can be productive with it.

Furthermore, if all developers on a project use only one IDE, there is
significant risk of dependencies on that IDE creeping into the build.  I feel
that Eclipse is especially vulnerable here; it does rather clever things with
classpaths that let a program run within the IDE, only to fail when you leave
Eclipse's hearth.  Testing should always occur on a command-line build
(preferably with Ant) before release.

That said, the earlier post about using an editor to insert a main() is not
such a joke.

We should get to pick our own editors; forcing standardization on a single IDE
in a project is an error.

- Lew
Chris Uppal - 30 Nov 2006 12:56 GMT
> Why the heck do so many managers seem bent on mandating IDEs?

I can think of a couple of reasons.

One (bad, but plausible) is that the project had /already/ become dependent on
the IDE.

Another (much better) is that knowledger dissemination within a team works much
better if everyone needs (roughly) the same knowledge.

One particularly extreme instance of the latter point is that some programmers,
if they don't know how to do something, will simply not do it.  If you have
someone(s) like that on your team then it's vital that there be other people on
the team who can show them "its easy, see, just do <whatever>".  (Such people
aren't necessarily bad programmers otherwise, but they can be damaging if left
uncontrolled.)

I'm not suggesting there aren't downsides too -- one that would concern me
about Eclipse specifically is that it uses its own compiler instead of javac.

   -- chris
Mark Jeffcoat - 30 Nov 2006 19:08 GMT
> Furthermore, if all developers on a project use only one IDE, there is
> significant risk of dependencies on that IDE creeping into the build.
> I feel that Eclipse is especially vulnerable here; it does rather
> clever things with classpaths that let a program run within the IDE,
> only to fail when you leave Eclipse's hearth.  Testing should always
> occur on a command-line build (preferably with Ant) before release.

It's not obvious to me that being dependent on Eclipse is
really a problem, as long as you're still able to deploy
the project into its production environment. It's not like
Eclipse is going to go away.

(I do all my programming in Emacs. I've had to learn quite
a lot about Ant just so I could play with the Eclipse people.)

Signature

Mark Jeffcoat
Austin, TX

David Segall - 01 Dec 2006 15:24 GMT
>Why the heck do so many managers seem bent on mandating IDEs?
>
>The choice of IDE is, or should be, completely immaterial to the finished
>product.  The ultimate deployment environment is command-line, with Ant.
I don't agree that it "should" be. It is, for example, possible to
write a GUI in Java. It is also possible to write the GUI in the "high
level language" provide by any of several IDEs. I prefer to use the
latter despite the fact that it is not portable between IDEs.

>We should get to pick our own editors; forcing standardization on a single IDE
>in a project is an error.
There is a raft of tools that come with an IDE. Many provide developer
collaboration including bug tracking, source code control and project
management. I don't think it is an "error" to enforce standards by
mandating an IDE.
Thomas Kellerer - 25 Nov 2006 02:16 GMT
sss wrote on 25.11.2006 02:11:
> So no optoin to add main function to class with check box?
> Maybe stick with Eclipse is the right solution.

Just because you need a wizard to create a main class?

Btw: I created an abbreviation for that: I simply type psm[blank] and voila I
have main method...

Thomas
nalhawash - 25 Nov 2006 03:25 GMT
agreed

Nasser
Alhawash

> sss wrote on 25.11.2006 02:11:
> > So no optoin to add main function to class with check box?
[quoted text clipped - 6 lines]
>
> Thomas
Lion-O - 27 Nov 2006 20:30 GMT
>> So no optoin to add main function to class with check box?
>> Maybe stick with Eclipse is the right solution.
[quoted text clipped - 3 lines]
> Btw: I created an abbreviation for that: I simply type psm[blank] and voila I
> have main method...

Why? ;)  The default abbreviation is "psvm<space>" ;-)

Signature

Groetjes, Peter

.\\ PGP/GPG key: http://www.catslair.org/pubkey.asc

Eric Sosman - 25 Nov 2006 14:35 GMT
> So no optoin to add main function to class with check box?
> Maybe stick with Eclipse is the right solution.

    When you're doing a New to add a new class, the menu
offers (among other things) "Java Main Class."  Care to
give it a try?

Signature

Eric Sosman
esosman@acm-dot-org.invalid



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.