I have the following doubts about a simple Java command-line application.
So, I have this command line application that is launched using the main () method defined inside the Main class.
As usual, this main () method is defined by this signature:
public static void main(String[] args) {
So the return type is void . Therefore, this should mean that it does not return any value.
But why, when its execution finishes correctly, do I get this message in the IntelliJ console?
Disconnected from the target VM, address: '127.0.0.1:54090', transport: 'socket' Process finished with exit code 0
What exactly is exit code 0 ?
I think this means that the program completed its execution correctly without introducing any errors.
So now I have the following two doubts:
If this is true, why does this happen if my main () method returns void ?
How can I return a different exit code if my application fails? Is there a default exit code value for error completion?
Tpx
java java-ee main exit-code
AndreaNobili
source share