> For the complete documentation index, see [llms.txt](https://unisim-soft.gitbook.io/unisim-soft/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://unisim-soft.gitbook.io/unisim-soft/razrabotka/obekty-oracle/pakety-java/paket-host.md).

# Пакет Host

{% code title="Host.java" %}

```java
CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "Host" as import java.io.*;
public class Host {
public static void executeCommand(String command) {
try {
String[] finalCommand;
final Process pr;
// Для windows указываем путь к cmd.exe и параметры выполнения команды
if (isWindows()) {
finalCommand = new String[4];
// Use the appropriate path for your windows version.
finalCommand[0] = "C:\\windows\\system32\\cmd.exe";  // Windows XP/2003
//finalCommand[0] = "C:\winnt\system32\cmd.exe";  // Windows NT/2000
finalCommand[1] = "/y";
finalCommand[2] = "/c";
finalCommand[3] = command;
//final Process pr = Runtime.getRuntime().exec(new String(args.getBytes("utf8")));
pr = Runtime.getRuntime().exec(finalCommand);
}  // Для linux вызываем выполнение команды
else {
pr = Runtime.getRuntime().exec(new String(command.getBytes("utf8")));
}
pr.waitFor();
new Thread(new Runnable(){
public void run() {
BufferedReader br_in = null;
try {
br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String buff = null;
while ((buff = br_in.readLine()) != null) {
System.out.println("Process out :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
}
br_in.close();
}
catch (IOException ioe) {
System.out.println("Exception caught printing process output.");
ioe.printStackTrace();
}
finally {
try {
br_in.close();
} catch (Exception ex) {}
}
}
}).start();
new Thread(new Runnable(){
public void run() {
BufferedReader br_err = null;
try {
br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
String buff = null;
while ((buff = br_err.readLine()) != null) {
System.out.println("Process err :" + buff);
try {Thread.sleep(100); } catch(Exception e) {}
}
br_err.close();
}
catch (IOException ioe) {
System.out.println("Exception caught printing process error.");
ioe.printStackTrace();
}
finally {
try {
br_err.close();
} catch (Exception ex) {}
}
}
}).start();
//return 1;
}
catch (Exception ex) {
System.out.println(ex.getLocalizedMessage()
//return -99;
);
}
}
public static boolean isWindows() {
if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
return true;
else
return false;
}
};
/
```

{% endcode %}
