javafx下启动spoon和carte

import javafx.application.Application;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.layout.VBox;

import javafx.stage.Stage;

import java.io.File;

public class PDIStarter extends Application {

@Override

public void start(Stage primaryStage) {

Button startCarteBtn = new Button("启动 Carte 服务");

Button startSpoonBtn = new Button("启动 Spoon");

Button stopAllBtn = new Button("停止所有服务");

startCarteBtn.setOnAction(e -> startCarte());

startSpoonBtn.setOnAction(e -> startSpoon());

stopAllBtn.setOnAction(e -> stopAllServices());

VBox root = new VBox(10, startCarteBtn, startSpoonBtn, stopAllBtn);

Scene scene = new Scene(root, 300, 200);

primaryStage.setTitle("PDI 服务控制器");

primaryStage.setScene(scene);

primaryStage.show();

}

private void startCarte() {

try {

// 设置编码环境变量

ProcessBuilder pb = new ProcessBuilder(

"cmd.exe", "/c",

"chcp", "65001", "&&",

"set", "JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8", "&&",

"set", "KETTLE_NATIVE=Y", "&&",

"cd", "/d", "D:\\dev_install\\pdi-ce-9.4.0.0-343\\data-integration", "&&",

"start", "carte.bat", "127.0.0.1", "8819"

);

pb.start();

System.out.println("Carte 服务启动中...");

} catch (Exception e) {

e.printStackTrace();

}

}

private void startSpoon() {

try {

ProcessBuilder pb = new ProcessBuilder(

"cmd.exe", "/c",

"chcp", "65001", "&&",

"set", "JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8", "&&",

"set", "KETTLE_NATIVE=Y", "&&",

"cd", "/d", "D:\\dev_install\\pdi-ce-9.4.0.0-343\\data-integration", "&&",

"start", "spoon.bat"

);

pb.start();

System.out.println("Spoon 启动中...");

} catch (Exception e) {

e.printStackTrace();

}

}

private void stopAllServices() {

try {

ProcessBuilder pb = new ProcessBuilder(

"cmd.exe", "/c",

"taskkill", "/f", "/im", "java.exe",

"&&", "taskkill", "/f", "/im", "spoon.bat"

);

pb.start();

System.out.println("已停止所有服务");

} catch (Exception e) {

e.printStackTrace();

}

}

public static void main(String[] args) {

launch(args);

}

}

相关推荐
zfoo-framework1 天前
帧同步和状态同步
java
charlotte102410241 天前
高并发:关于在等待学校教务系统选课时的碎碎念
java·运维·网络
亓才孓1 天前
[JDBC]PreparedStatement替代Statement
java·数据库
_F_y1 天前
C++重点知识总结
java·jvm·c++
打工的小王1 天前
Spring Boot(三)Spring Boot整合SpringMVC
java·spring boot·后端
毕设源码-赖学姐1 天前
【开题答辩全过程】以 高校体育场馆管理系统为例,包含答辩的问题和答案
java·spring boot
我真会写代码1 天前
SSM(指南一)---Maven项目管理从入门到精通|高质量实操指南
java·spring·tomcat·maven·ssm
vx_Biye_Design1 天前
【关注可免费领取源码】房屋出租系统的设计与实现--毕设附源码40805
java·spring boot·spring·spring cloud·servlet·eclipse·课程设计
DN金猿1 天前
接口路径正确,请求接口却提示404
java·tomcat
Maynor9961 天前
OpenClaw 玩家必备:用 AI 自动追踪社区最新动态
java·服务器·人工智能