× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Sam,

Thanks for the informative response.

I understand that calling Java from RPG can be a performance headache, but
in our shop, with 1 RPG programmer, and a requirement for allot of
spreadsheets at certain times during the month, this is really our only
option considering there are no Java programmers here. I dabble in it, but
that's about it.

The class I wrote, is to replace a sub-procedure, written in RPG, to open
an existing Excel Workbook. The subprocedure, on my system, did not work. I
couldn't get any information out of the system as to why the Exception was
occurring. So, I decided to write basically the same code in Java, in order
to see why the code was failing. This prompted my query for information as
to how to see what comes out of System.out. In all the testing, though, the
class works. It does return the workbook. I modified it a bit to write out
a small error log if there is an error. This works as well. This program
will be run once a month. I've tested it and it works fine. Although, like
you said, there are performance issues.

I look forward to learning more about Java programming. But, I need to
serve my employer first.

Thanks again for the help,

Regards,

Mark

Mark D. Walter
Senior Programmer/Analyst
CCX, Inc.
mwalter@xxxxxxxxxx
http://www.ccxinc.com


                                                                           
             "Joe Sam Shirah"                                              
             <jshirah@attgloba                                             
             l.net>                                                     To 
             Sent by:                  "Java Programming on and around the 
             java400-l-bounces         iSeries / AS400"                    
             @midrange.com             <java400-l@xxxxxxxxxxxx>            
                                                                        cc 
                                                                           
             06/08/2005 04:33                                      Subject 
             PM                        Re: Trying to get output from       
                                       System.out.                         
                                                                           
             Please respond to                                             
             Java Programming                                              
             on and around the                                             
              iSeries / AS400                                              
             <java400-l@midran                                             
                  ge.com>                                                  
                                                                           
                                                                           




----------
    I contacted Mark off-list because it wasn't clear to me if Colin's
response resolved things and I didn't want to clutter the list with just an
inquiry.  Mark's response is below and I will refer to it later on.
----------


    I will just briefly state my opinion that the biggest problem is
calling
Java apps from RPG.  It seems cool, but there are lots of issues, and
performance/memory becomes a real headache with multiple users.  We never
have these problems because we just don't do it.  JNI has its place, but
normally asynchronous processing is the answer.  We use messaging due to
several benefits; others do the same with data queues.

    BTW, my conclusions are educated guesses.  We don't do things this way,
so it has zero educational value for me, and as a business owner I don't
get
to eat unless I bill, so there's no incentive to go through testing.  With
that said,

    First, standard IFS files are in ASCII.  I think your initial problem
is
that EBCDIC is getting loaded into the file.  From what I can tell about
QIBM_USE_DESCRIPTOR_STDIO, while most of the documentation deals with PASE
and C code, I think the RPG programs job log and/or messages are getting
put
to the IFS file as stdout and stderr.  I may be wrong, but it fits your
description.  So, the first thing I would try is ditching that environment
variable.  See

File systems

<
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzalf/rzalffilesystems.htm

>

for *some* information.

    Next, I wouldn't use SystemDefault.properties.  That could get to be a
maintenance headache one way or another.  In addition, I suspect that it
would cause previous data to be overwritten, although I'm not 100% certain
of that - depends on how the default out/err is opened.

    Colin's code ( which includes buffering ) should work fine.  The
general
basic form is:

        // set out, err
       System.setErr(
          new PrintStream(
             new FileOutputStream(
               "/myDir/myLog.log", true ) ) );

       System.setOut(
          new PrintStream(
             new FileOutputStream(
               "/myDir/myLog.log", true ) ) );

    Two things about your code below:  You never set System.out or
System.err, and, opening and closing files is expensive.  For this purpose,
you should only do it once per program.  Otherwise, there's nothing that
strikes me as obviously wrong, although you don't need

        fs.close();

after

        ps.close();

    Maybe there's no text associated with getMessage() for the error?  Try
writing another string as well.  HTH,


                                                         Joe Sam

Joe Sam Shirah -        http://www.conceptgo.com
conceptGO       -        Consulting/Development/Outsourcing
Java Filter Forum:       http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International?    http://www.jguru.com/faq/I18N
Que Java400?            http://www.jguru.com/faq/Java400


----- Original Message -----
From: <MWalter@xxxxxxxxxxxxxxx>
To: "Joe Sam Shirah" <jshirah@xxxxxxxxxxxxx>
Sent: Wednesday, June 08, 2005 2:15 PM
Subject: Re: Trying to get output from System.out.


> It makes sense, but I can't get it to work. Here's what I've done playing
> with this:
>
> public class WorkbookObject {
>
>             public HSSFWorkbook getWorkbookHandle (String pathToFile)
>       {
>
>             try {
>                   FileInputStream fs = new FileInputStream(pathToFile);
>                   POIFSFileSystem pfs = new POIFSFileSystem(fs);
>                   HSSFWorkbook wb = new HSSFWorkbook(pfs);
>                   fs.close();
>                   String tempString = "This Worked";
>                   writeErrorLog(tempString);
>                   return wb;
>
>             }
>             catch (Exception e){
>                   writeErrorLog(e.getMessage());
>                   return null;
>             }
>       }
>
>       private void writeErrorLog (String error)
>       {
>             try {
>                         String errorFileString = "/javalog/myErrors.log";
>                         FileOutputStream fs = new
> FileOutputStream(errorFileString,true);
>                         PrintStream ps = new PrintStream(fs);
>                         ps.println(error);
>                         ps.close();
>                         fs.close();
>                         }
>                         catch (Exception ioe){
>
>                         }
>       }
> }
>
>
> I get nothing in myErrors.log
>
> Obviously I'm a Java Rookie. Again this is being called from RPG.
>
> Thanks,
>
> Mark
>
> Mark D. Walter
> Senior Programmer/Analyst
> CCX, Inc.
> mwalter@xxxxxxxxxx
> http://www.ccxinc.com
>

--
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.