ExecutionUtils
Execution related methods. For example, to run a script or JAR.
Methods
runScript
Description:
Method | Return values | Description |
---|---|---|
runScript(File script) |
Object[] |
Execute script from file. |
script: The name of the file to run. |
Example:
package com.openkm;
import java.io.File;
import com.openkm.core.Config;
import com.openkm.util.ExecutionUtils;
public class Test {
public static void main(String[] args) {
try {
File script = new File("/home/openkm/test.bsh");
ExecutionUtils.runScript(script);
} catch (Exception e) {
e.printStackTrace();
}
}
}
runJar
Description:
Method | Return values | Description |
---|---|---|
runJar(File jar) |
Object |
Execute jar from file. |
jar: The name of the file to run. |
Example:
package com.openkm;
import java.io.File;
import com.openkm.util.ExecutionUtils;
public class Test {
public static void main(String[] args) {
try {
File jar = new File("/home/openkm/test.jar");
ExecutionUtils.getInstance().runJar(jar);
} catch (Exception e) {
e.printStackTrace();
}
}
}
runCmd
Description:
Method | Return values | Description |
---|---|---|
runCmd(String cmd) |
CmdExecutionResult |
Execute command line. |
cmd: The command line to execute. |
Example:
package com.openkm;
import com.openkm.util.ExecutionUtils;
public class Test {
public static void main(String[] args) {
try {
ExecutionUtils.runCmd("mkdir test");
} catch (Exception e) {
e.printStackTrace();
}
}
}