How do I return a return-code from main?

W

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
 
C

Collin VanDyck

wl said:
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)
 
D

Dimitri Maziuk

Collin VanDyck sez:
wl said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top