473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How do I return a return-code from main?

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
2 13707
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Marco Aschwanden | last post by:
Hi I checked the other day a module of mine with pylint. And for some function it told me, that I was using too many return-statements in my code... there were about 5 or 7 of them in my...
8
by: george young | last post by:
I recently found myself writing something like: def get_connection(): if tcp_conn(): if server_allows_conn(): return 'good_conn' else: return 'bad_auth' else: return 'no_server'
20
by: Jakob Bieling | last post by:
Hi! I am using VC++ 7.1 and have a question about return value optimization. Consider the following code: #include <list> #include <string> struct test {
15
by: Greenhorn | last post by:
Hi, when a function doesn't specify a return type ,value what value is returned. In the below programme, the function sample()is returning the value passed to 'k'. sample(int); main() { int...
3
by: tshad | last post by:
I am trying to set up a class to handle my database accesses. I can't seem to figure out how to get the return value from my dataReader from these routines (most of which I got elsewhere). They...
2
by: 6kjfsyg02 | last post by:
I am trying to return one of two different objects from the same method, but I can not do it in WSDL or C#. I have a web service with three methods. I have been told that one of the methods...
14
by: tshad | last post by:
Is there any difference between Return and Exit Sub? I have some code that uses both when I have an error in my Sub. Thanks, Tom
8
by: WakeBdr | last post by:
I'm writing a class that will query a database for some data and return the result to the caller. I need to be able to return the result of the query in several different ways: list, xml,...
13
by: cppquester | last post by:
A colleague told me that there is a rule about good stype that a function in C++ should have only one point of return (ie. return statement). Otherwise there might be trouble. I never heard about...
18
by: terminator(jam) | last post by:
consider: struct memory_pig{//a really large type: memory_pig(){ std::cout<<"mem pig default\n"; //etc... }; memory_pig(memory_pig const&){
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.