Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Enhancement request

Reply
Thread Tools

Enhancement request

 
 
Mike Schilling
Guest
Posts: n/a
 
      09-04-2008
Tegiri Nenashi wrote:
> I'm programming java since 96 and can't remember myself ever using
> main method with arguments. Does anybody have a different
> experience?


Yes, for any command-line program. The arguments to main are the
command's flags and parameters.


 
Reply With Quote
 
 
 
 
Mike Schilling
Guest
Posts: n/a
 
      09-04-2008
Lew wrote:
> Tegiri Nenashi wrote:
>>> static void main() {
>>> }

>
> Mark Space wrote:
>> Forgot the "public."

>
> Unless you call it from another Java class in a different package,
> 'main()' doesn't need to be public.


It's not callable from the command line unless it's public.

class Hello
{
static void main(String[] args)
{
System.out.println("Hello.world.");
}
}


% java -cp . Hello
Main method not public.


 
Reply With Quote
 
 
 
 
Tegiri Nenashi
Guest
Posts: n/a
 
      09-04-2008
On Sep 4, 8:27*am, Stefan Rybacki <noem...@noemail.foobar> wrote:
> Tegiri Nenashi schrieb:
>
> >...

>
> > When creating new class, yes. There doesn't seem to be any way to add
> > main method to existing class in eclipse.

>
> Sure there is: type main and do auto completion it should provide you a template
> called main -> use it.


Indeed: "mai"<ctrl-space> not much to type! Thank you.
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      09-04-2008
Raoul Winger wrote:
> What i would support would be an int return type from main, so you can
> return an exit code to the OS. I don't see why one should have to use
> System.exit to do that.


I think it would have been aforesaid if they had done it that way. But
they did not and I don't think it is astral enough to justify
a change.

You can forever just write your own tajava.c->tajava.exe with
that functionality.

Seth


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
President Bush's grandfather (Prescott Bush) was a director
of a bank seized by the federal government because of its ties
to a German industrialist who helped bankroll Adolf Hitler's
rise to power, government documents show.

http://story.news.yahoo.com/news?tmp...on_re_us/presc
ott_bush_nazis_1

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This is just a reminder.
It is not an emergency yet.
Were it actual emergency, you wouldn't be able to read this.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      09-04-2008
Katya Van Gogh wrote:
> On Wed, 3 Sep 2008, Lionel van den Berg wrote:
>> On Sep 4, 2:31 pm, Tegiri Nenashi <TegiriNena...@gmail.com> wrote:
>>> I'm programming java since 96 and can't remember myself ever using
>>> main method with arguments. Does anybody have a different experience?

>>
>> I've used them, mainly when running from commandline.

>
> Same here. I've used them a lot.


So have I, but of the considerate types of Skull and Bombs tails:
- SE console cabages
- SE Idol softwares
- SE pears
- EE plates
- ME whatever such hotdogs are called
only the first notation is potential command clue volumes.

I celebrate that timeout is smooth enough to justify the feature though.

Quinton


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"There's not going to be enough people in the system
to take advantage of people like me."

--- Adolph Bush,
On the coming Social Security crisis;
Wilton, Conn.; June 9, 2000 (Thanks to Andy Mais.)

 
Reply With Quote
 
zerg
Guest
Posts: n/a
 
      09-04-2008
Eric Sosman wrote:
> One can imagine a System.getArguments() method returning a String[]
> containing the command-line arguments. But the current scheme is more
> flexible: For example, a method in one class can call the main() of
> another class with a specially-tailored set of "command-line" arguments.
> It's hard to see how that could be done with System.getArguments(),
> particularly in a multi-threaded application.


Of course, this suggests another reason why an int return value for main
might be desirable, too.

On the other hand, throwing an exception would be the Java way to report
an error status to a caller, not returning a cryptic int.

That, and the actual (void) return type of main, suggest the "write your
app as a library plus a main function" approach. Then when another app
needs to subsume the functionality, instead of invoking the first app's
main, it just invokes the library invoked by the first app's main. Some
of the library's methods presumably being capable of throwing exceptions.
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      09-05-2008
Tegiri Nenashi wrote:
> I suggest the main method is used a lot more often than one per
> application. I test every sophisticated method by invoking from the
> main, e.g.
>
> Class Topology {
> ...
> public static void main( String[] args ) {
> Cylinder c = new Cylinder("a",10,10,10,10);
> Topology t = new Topology(c);
> System.out.println(t.getOpenings());
> }
> }
>
> Therefore, almost every class has it. With this usage scenario it is
> unjustifiably verbose.


Most people uses unit tests instead of main's.

Arne
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      09-05-2008
Tegiri Nenashi wrote:
> Next, the others mentioned that the return value of the method is
> communicated via System.exit(). Wouldn't elementary consistency
> suggest that input arguments should be passed in a similar venue?


Why ?

Input arguments and return status does not seem to be very related.

Arne
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      09-05-2008
Tom Anderson wrote:
> On Wed, 3 Sep 2008, Lionel van den Berg wrote:
>> On Sep 4, 2:31 pm, Tegiri Nenashi <TegiriNena...@gmail.com> wrote:
>>> I'm programming java since 96 and can't remember myself ever using
>>> main method with arguments. Does anybody have a different experience?

>>
>> I've used them, mainly when running from commandline.

>
> Same here. I've used them a lot.


So have I, but of the different types of Java apps:
- SE console apps
- SE GUI apps
- SE applets
- EE apps
- ME whatever such apps are called
only the first category is potential command line arguments.

I believe that category is large enough to justify the feature though.

Arne
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      09-05-2008
Tom Anderson wrote:
> What i would support would be an int return type from main, so you can
> return an exit code to the OS. I don't see why one should have to use
> System.exit to do that.


I think it would have been fine if they had done it that way. But
they did not and I don't think it is important enough to justify
a change.

You can always just write your own tajava.c->tajava.exe with
that functionality.

Arne
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Column numbers in stack trace - enhancement request Sasi Java 13 01-22-2007 08:12 PM
Column numbers is stack trace - enhancement request Sasi Java 2 01-15-2007 12:55 PM
Firewall software enhancement suggestion ultimotion@gmail.com Cisco 0 11-29-2005 02:25 PM
Re: Accessing Request.InputStream / Request.BinaryRead *as the request is occuring*: How??? Brian Birtle ASP .Net 2 10-16-2003 02:11 PM
Re: asp.net calendar enhancement Marlene ASP .Net 0 06-25-2003 04:23 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57