GeeCON Prague 2014*
The moose likes Java in General and the fly likes How to pass Java value from program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "How to pass Java value from program" Watch "How to pass Java value from program" New topic
Author

How to pass Java value from program

bob connolly
Ranch Hand

Joined: Mar 10, 2004
Posts: 204
Hello,

I thought i'd be able to use the System.exit(calcval) to pass a final value of the a Java program and into a kshell variable ie:

#!bin/ksh

java jpgm1
passvar=$?

but it looks like the .exit method only passes numeric values up to a certain value, ie under 500 looks like.

Is there another Java method i could use to accomplish this same feat?

I could write it to a file of course, but then i would need to figure a way to get it from the file to the $passvar!

Thanks for any suggestions!
bc
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30596
    
154

Bob,
I'm not familiar with the limits of System.exit(), but I do know how to read in a file in UNIX:
passvar=`cat fileName`

(Note that the example has backquotes, not regular quotes)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
bob connolly
Ranch Hand

Joined: Mar 10, 2004
Posts: 204
Thanks alot Jeanne!

bc
 
GeeCON Prague 2014
 
subject: How to pass Java value from program