|
Patrick,
If you don't want QSH flashing with messages sent by System.out.printxx
when calling Java from RPG you can use following solution by redirecting
System.out
to a log file. No flashing occurs (at least when I used my example) when calling
the RPG2JAVA2 program. You could control the redirection by an extra parameter
when calling your methods. (or use a Properties file, ...)
kind regards,
Geert Van Landeghem
Reynders Etiketten NV
Tel: 03/460.32.81
GSM: 0477/75.95.33
gvl@reynders.com
*******************************************************************************
Example DateDemo.java
*******************************************************************************
import java.io.*;
import java.text.*;
import java.util.*;
public class DateDemo
{
public static void main(String args[])
{
printDemo();
}
public static void printDemo() {
try {
// Redirecting System.out to a log file.
System.setOut(new PrintStream(new
FileOutputStream("/home/gvl/java.txt")));
}
catch(Exception e) {
}
Date curDate = new Date();
DateFormat df;
df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
System.out.println("United States : " + df.format(curDate));
df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.UK);
System.out.println("United Kingdom : " + df.format(curDate));
df = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE);
System.out.println("France : " + df.format(curDate));
df = DateFormat.getDateInstance(DateFormat.FULL, Locale.GERMANY);
System.out.println("Germany : " + df.format(curDate));
}
}
*******************************************************************************
RPG2JAVA2
*******************************************************************************
H dftactgrp(*no) actgrp(*new)
* Prototype for printDemo
D printDemo PR ExtProc(*JAVA
D :'DateDemo'
D :'printDemo')
D static
/Free
// Call the printDemo method.
printDemo();
*Inlr = *on;
/End-Free
After calling RPG2JAVA
*******************************************************************************
Edit File: /home/gvl/java.txt
Record : 1 of 4 by 10 Column : 1 59
by 126
Control :
CMD
....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....0....+....1....+....2....+..
************Beginning of data**************
United States : 8/9/02
United Kingdom : 09-Aug-02
France : 9 août 2002
Germany : Freitag, 9. August 2002
************End of Data********************
-----Original Message-----
From: P.Goovaerts@Clipper.Be [mailto:P.Goovaerts@Clipper.Be]
Sent: vendredi 9 août 2002 14:20
To: java400-l@midrange.com
Subject: Re: STDOUT to file
This is a multipart message in MIME format.
--
[ Picked text/plain from multipart/alternative ]
I read through this thread already. All examples are starting with RUNJVA
command through QSH though! I tried an example (to redirect it) and the
result is that output from QSH itself is indeed written to a file on ifs.
I want to do this but starting from RPG, calling JAVA. This isn't
described anywhere.
This is my procedure:
Call CL
- sets 'classpath' environment variable
- call RPG program using 'call' cmd
- remove 'classpath' environment
The RPG program call's javamethod's using callp.
I found a way to redirect the output of QSH to an ifs-file (setting a
specific variable). Then I changed the cl to test it:
Call CL
- sets 'classpath' environment variable
- sets 'QIBM...=FILE='mydir/myfile' variable
- QSH CMD('ENV')
- call RPG program using 'call' cmd
- remove 'QIBM...=FILE='mydir/myfile' variable
- remove 'classpath' environment
Result is that the output from the QSH-cmd is printed in 'myfile', the
output from the javamethod's are still shown on the 5250-screen.
" I don't have problems, only challenges... "
Patrick Goovaerts
WebMaster
Clipper Support nv
TEL : 0032 (0)3 5453991
GSM: 0498 610 325
WEB: www.conti7.be
From: "Jon Paris" <Jon.Paris@Partner400.com>
To: <java400-l@midrange.com>
Subject: STDOUT to file
Date: Thu, 8 Aug 2002 17:53:16 -0400
Reply-To: java400-l@midrange.com
>> Any suggestions on how to do this?
There has been a lengthy thread on this topic on the WEB400 list on this
server (www.midrange.com) check the archives at the web site. There are a
couple of solutions suggested there - I don't know for sure if it will
work
for Java based apps - but can't think of why it shouldn't.
Jon Paris
Partner400
_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l
or email: JAVA400-L-request@midrange.com
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 mailing list archive is Copyright 1997-2025 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.