This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

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
 
Consider Paul's rocket mass heater.
 
subject: How to pass Java value from program
 
Similar Threads
return value from main
Drop Down Variable
Sample database structure
Print Properties
beginning methods help