How to call informix-4gl from java?

B

busybee

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.
 
K

kaeli

shkk13 said:
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);
}
}
}

--
 
B

busybee

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 said:
shkk13 said:
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);
}
}
}

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top