How to call informix-4gl from java?  
Author Message
shkk13





PostPosted: 2004-2-17 14:45:00 Top

java-programmer, How to call informix-4gl from java? Hello gurus,
Would anybody let me how to call informix-4gl program from java?
Please show this with a simple example if possible. I use character
interfaced 4GL, not GUI enabled D4GL. I would welcome any feedback in
this regard. Thanks.
 
kaeli





PostPosted: 2004-2-17 21:40:00 Top

java-programmer >> How to call informix-4gl from java? In article <email***@***.com>, shkk13
@yahoo.com enlightened us with...
> Hello gurus,
> Would anybody let me how to call informix-4gl program from java?
> Please show this with a simple example if possible. I use character
> interfaced 4GL, not GUI enabled D4GL. I would welcome any feedback in
> this regard. Thanks.
>

I have no idea what that is, but pretty much any program that can be
called from the DOS command line (or Unix) can be executed using
Runtime.exec.

A small example - my code that calls a process. Both servers are
Solaris. (Modified for sensitive content.)

import java.io.*;
import java.net.*;

public class callForeignServer
{
public static void main(String[] args) throws IOException
{
String [] command = {"rsh","-l","username",
"remotemachine.com",
"pathToCommand/command arg1 arg2 arg3"};
String results="";
String error="";
String s;

try
{
Process p = Runtime.getRuntime().exec(command);
InputStream in1 = p.getInputStream();
InputStream err1 = p.getErrorStream();
BufferedReader in = new BufferedReader(new InputStreamReader
(in1));
BufferedReader err = new BufferedReader(new InputStreamReader
(err1));

// read the output from the command

System.out.println("Here is the standard output of the command:
\n");
while ((s = in.readLine()) != null)
{
System.out.println(s);
}

// read any errors from the attempted command

System.out.println("Here is the standard error of the command
(if any):\n");
while ((s = err.readLine()) != null)
{
System.out.println(s);
}
p.waitFor();
System.out.println(p.exitValue());
}
catch (Exception e)
{
System.err.println(e.getMessage());
System.exit(1);
}
}
}

--
 
shkk13





PostPosted: 2004-2-20 17:01:00 Top

java-programmer >> How to call informix-4gl from java? Hi kaeli,

Your post has helped me a lot. I am a newbie to Java programming.
Thank you very much. BTW, Informix-4GL is an application development
tool meant only for Informix back-end databases.

Thanks again.

kaeli <email***@***.com> wrote in message news:<email***@***.com>...
> In article <email***@***.com>, shkk13
> @yahoo.com enlightened us with...
> > Hello gurus,
> > Would anybody let me how to call informix-4gl program from java?
> > Please show this with a simple example if possible. I use character
> > interfaced 4GL, not GUI enabled D4GL. I would welcome any feedback in
> > this regard. Thanks.
> >
>
> I have no idea what that is, but pretty much any program that can be
> called from the DOS command line (or Unix) can be executed using
> Runtime.exec.
>
> A small example - my code that calls a process. Both servers are
> Solaris. (Modified for sensitive content.)
>
> import java.io.*;
> import java.net.*;
>
> public class callForeignServer
> {
> public static void main(String[] args) throws IOException
> {
> String [] command = {"rsh","-l","username",
> "remotemachine.com",
> "pathToCommand/command arg1 arg2 arg3"};
> String results="";
> String error="";
> String s;
>
> try
> {
> Process p = Runtime.getRuntime().exec(command);
> InputStream in1 = p.getInputStream();
> InputStream err1 = p.getErrorStream();
> BufferedReader in = new BufferedReader(new InputStreamReader
> (in1));
> BufferedReader err = new BufferedReader(new InputStreamReader
> (err1));
>
> // read the output from the command
>
> System.out.println("Here is the standard output of the command:
> \n");
> while ((s = in.readLine()) != null)
> {
> System.out.println(s);
> }
>
> // read any errors from the attempted command
>
> System.out.println("Here is the standard error of the command
> (if any):\n");
> while ((s = err.readLine()) != null)
> {
> System.out.println(s);
> }
> p.waitFor();
> System.out.println(p.exitValue());
> }
> catch (Exception e)
> {
> System.err.println(e.getMessage());
> System.exit(1);
> }
> }
> }
>
> --