By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,655 Members | 1,860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,655 IT Pros & Developers. It's quick & easy.

How do I return a return-code from main?

P: n/a
wl
Hi all,
Pls help with the following:

I have a stand-alone java program which will need to return a return-code to
the running script. I thought I could just use:

return -1;

inside the "public static int main(String[] args)". However, I get an
error. Apparently, I can only have "public static void main(String[]
args)".

Is there a way I can return a return-code?

Thanks,
Bill
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"wl" <bl***@yahoo.com> wrote in message
news:1D*******************@newsread3.news.atl.eart hlink.net...
Hi all,
Pls help with the following:

I have a stand-alone java program which will need to return a return-code to the running script. I thought I could just use:

return -1;

inside the "public static int main(String[] args)". However, I get an
error. Apparently, I can only have "public static void main(String[]
args)".

Is there a way I can return a return-code?

Thanks,
Bill


Try System.exit(-1)

Jul 17 '05 #2

P: n/a
Collin VanDyck sez:
"wl" <bl***@yahoo.com> wrote in message
news:1D*******************@newsread3.news.atl.eart hlink.net...
Hi all,
Pls help with the following:

I have a stand-alone java program which will need to return a return-code

to
the running script. I thought I could just use:

return -1;

inside the "public static int main(String[] args)". However, I get an
error. Apparently, I can only have "public static void main(String[]
args)".

Is there a way I can return a return-code?

Thanks,
Bill


Try System.exit(-1)


In case you're wondering, it's JVM, not main() that returns to OS.
main() returns to JVM (which may or may not terminate then).

Dima
--
I like the US government, makes the Aussie one look less dumb and THAT is a
pretty big effort. -- Craig Small
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.