Redian新闻
>
is there anyway that i can return...
avatar
is there anyway that i can return...# Java - 爪哇娇娃
r*w
1
a value from a main() function of a class?
and
how can i get the return value of a function call in a shell script
such as
return_value="java my_prog";
if(return_value==0) do_something;
is it possible to achieve in java?
thanks~
avatar
e*g
2
System.exit(0);

【在 r*******w 的大作中提到】
: a value from a main() function of a class?
: and
: how can i get the return value of a function call in a shell script
: such as
: return_value="java my_prog";
: if(return_value==0) do_something;
: is it possible to achieve in java?
: thanks~

avatar
r*w
3
thanks~~~
is it possible to let "java my_prog" to return the value i returned in the
main function of class my_prog?
it seems to me (by a few small test programs) that "java my_prog" returns the
status code of the program "java"...not "my_prog"...
any workaround for this?
i need the return code of "my_prog" to run a batch job
thanks~

【在 e***g 的大作中提到】
: System.exit(0);
avatar
e*g
4
call System.exit(n) to terminate the program; n is returned to shell

【在 r*******w 的大作中提到】
: thanks~~~
: is it possible to let "java my_prog" to return the value i returned in the
: main function of class my_prog?
: it seems to me (by a few small test programs) that "java my_prog" returns the
: status code of the program "java"...not "my_prog"...
: any workaround for this?
: i need the return code of "my_prog" to run a batch job
: thanks~

avatar
r*w
5
maybe i am making a stupid mistake...but
here is what i do
class my_prog {
static public void main(String[] args) {
System.exit(-1);
}
}
another perl file:
$return_value=system("java my_prog");
print $return_value;
the print out is random values...each time different...
maybe i did something wrong in the perl file?

the

【在 e***g 的大作中提到】
: call System.exit(n) to terminate the program; n is returned to shell
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。