How does Java call external external commands?

zhaozj2021-02-16  55

My own experience is Runtime.Getruntime.exec (cmd);

For example, the following code:

String [] cmd = new string [3];

IF (OsName.equals ("Windows NT") || OsName.Equals ("Windows 2000")) {cmd [0] = "cmd.exe"; cmd [1] = "/ c";

Else IF (OsName.equals ("Linux"))

{

CMD [0] = "sh"

CMD [1] = a directory under Linux

} Else if ("Windows 98")) {cmd [0] = "command.com"; cmd [1] = "/ c";} cmd [2] = "mysqldump --opt -u root YH_TPL> " backup_path filename ". SQL "; Process PS = runtime.getRuntime (). EXEC (CMD);

I saw someone else to reply to this type of question, I didn't know like this:

The Java is transferred from EXEC to Java's JVM, so it requires yourself to maintain your own environment.

转载请注明原文地址:https://www.9cbs.com/read-19905.html

New Post(0)