This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes why main returns nothing always in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "why main returns nothing always in java" Watch "why main returns nothing always in java" New topic
Author

why main returns nothing always in java

rajeev maurya
Greenhorn

Joined: Nov 26, 2010
Posts: 1
why main returns nothing always in java
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Compared to C?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Because that's how the people who invented Java made it...

If you need to return a return value to the operating system (so that you can use it in for example a batch file or shell script), use System.exit(n); to end your Java program (where n is the return code).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

In C and C++, the return value of the main method can be used by the calling shell (e.g. bash). In Java, you use System.exit to give this value back to the calling shell.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Don't get me started about those stupid light bulbs.
 
subject: why main returns nothing always in java
 
Similar Threads
getMessage
signed float & double
Casting doubt
Clearing a system?
Wonder!!!!