devxlogo

Return Values from Java to Unix

Return Values from Java to Unix

Question:
I am calling a java program from a Unix script and passing threeparameters. Once the Java program is done, I want to return two valuesback to the Unix program from the Java program.

How do I return data backfrom a Java program to a Unix script?

Answer:
The simplest, and perhaps best, way to do this is to print the values tostandard output and parse them in the script. It is normal for shellscripts to use the printed output of other programs in one way oranother.

Another alternative is to write the values to a file. Otherforms of interprocess communication can be used, but provide overlycomplicated solutions for the simple case of returning values to ascript.

See also  5 Tips for Working With an Onsite Interpreter
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist