"Runtime.getRuntime().exec("{명령어}")"의 형태로 사용
import java.io.*;
public class CallHelloPgm
{
public static void main(String args[])
{
Process theProcess = null;
BufferedReader inStream = null;
System.out.println("CallHelloPgm.main() invoked");
// call the Hello class
try
{
theProcess = Runtime.getRuntime().exec("java QIBMHello");
}
catch(IOException e)
{
System.err.println("Error on exec() method");
e.printStackTrace();
}
// read from the called program's standard output stream
try
{
inStream = new BufferedReader(
new InputStreamReader( theProcess.getInputStream() ));
System.out.println(inStream.readLine());
}
catch(IOException e)
{
System.err.println("Error on inStream.readLine()");
e.printStackTrace();
}
}
}
import java.io.*;
public class CallCLPgm
{
public static void main(String[] args)
{
try
{
Process theProcess =
Runtime.getRuntime().exec("/QSYS.LIB/JAVSAMPLIB.LIB/DSPJVA.PGM");
}
catch(IOException e)
{
System.err.println("Error on exec() method");
e.printStackTrace();
}
}
}
import java.io.*;
public class CallCLCom
{
public static void main(String[] args)
{
try
{
Process theProcess =
Runtime.getRuntime().exec("system DSPJVMJOB OUTPUT(*PRINT)");
}
catch(IOException e)
{
System.err.println("Error on exec() method");
e.printStackTrace();
}
}
}