Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8293547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:51:54+00:00 2026-06-08T13:51:54+00:00

I am trying to invoke a simple Hello World Cobol program through java. The

  • 0

I am trying to invoke a simple Hello World Cobol program through java. The java code is in IFS file structure and the cobol object is parked in a library.
I am facing multiple problems:

  1. The error stream returned by process execution is not in readable format.
  2. I am getting error stream result even if the termination of cobol code returns 0.
  3. I cannot see the cobol output result in the inputstream of the process.(May be I can solve this if i understand the error stream )

The cobol code works when invoke independently.
I have tried encoding UTF8,UTF16, Cp943 and default.
When I use UTF8,UTF16 I get MalformedInputException, else a garbage value.

Java code:(compiled @ AS 400 itself -java 1.5)


    import java.io.*;

    public class CallCLPgm
    {
       public static void main(String[] args)
       {
          try
          {
          Process theProcess =  Runtime.getRuntime().exec("system CALL PROG6");
          //error stream
            BufferedReader inStream1 = new BufferedReader(new InputStreamReader
                     (theProcess.getErrorStream(),"UTF8"));
             System.out.println(inStream1.readLine());
            inStream1.close();
          //input stream   
             BufferedReader inStream = new BufferedReader(new InputStreamReader
                     (theProcess.getInputStream()));
             System.out.println(inStream.readLine());
             inStream.close();


             System.out.println("termination : "+theProcess.waitFor());

 
 //Cobol code
      PROCEDURE DIVISION.        
      PROGRAM-BEGIN.     
          DISPLAY "Hello World".   
          STOP RUN.  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:51:55+00:00Added an answer on June 8, 2026 at 1:51 pm

    I should have focused on IBM encoding format
    http://publib.boulder.ibm.com/html/as400/v4r5/ic2924/index.htm?info/java/rzaha/fileenc.htm

    I used “Cp037” for USA instead of UTF8 and other format.

    BufferedReader inStream1 = new BufferedReader(new InputStreamReader
    (theProcess.getErrorStream(),”Cp037″));

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to invoke the method typeOfInstance() in the following (simplest) code: import
I am trying to invoke an ANT target from Windows (right-click) file context menu.
I'm trying to save a data in a simple form through Hibernate using struts
I have a really simple program where I'm trying to add a directory to
I am trying to run a very simple server/client ssl code with a self
I am trying to invoke a simple procedure in assembly, but I cannot get
I'm getting frustrated trying to do a simple thing - I want to invoke
I'm trying to write a simple object to Dictionary converter like below: public static
I am trying to write a simple program where i can put a HashMap
I am trying to learn P/Invoke, so I created a simple dll in C++

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.