方法1:直接在Java中执行shell命令
```java
import java.io.;
public class Main {
public static void main(String[] args) {
try {
// 执行一个shell命令
ProcessBuilder processBuilder = new ProcessBuilder("sh", "-c", "echo 'Hello, World!'");
Process process = processBuilder.start();
// 读取命令执行结果
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);