The main method of a Java class cannot return
a value.
However, I guess what you are looking for is
some way to let another application or a calling
script know how you program has terminated.
Let's put it this way: when you return form the
main method it means your application has finished
its job.
So what you can do is to use a static exit method
of the System class:
System.exit(<integer value>);
If you are are under Unix and your JVM was launched
from any Unix shell, you can get the value passed
to the exit method by using shell special variable $?.
In DOS/Windows you can use %ERRORLEVEL% variable
if you are using .cmd or .bat files to launch
your Java program.
Clarify what your goal is and may be we could
assist you more...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.