devxlogo

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.

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Five Early Architecture Decisions That Quietly Get Expensive

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.