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);

}

}

相关推荐
evans在进步35 分钟前
Tomcat NIO 工作原理详解:从 Acceptor、Poller 到容器处理链
java·tomcat·nio
渡我白衣2 小时前
并查集:基础认识与模拟实现
android·java·javascript·数据结构·c++·算法·并查集
电商API_180079052472 小时前
电商商品价格监控工具淘宝京东商品价格抓取API项目实操分享
java·大数据·开发语言·前端·数据挖掘
zzzll11112 小时前
深度剖析:HashMap 并发死循环与 ConcurrentHashMap 两代演进全解
java·开发语言
秋名RG2 小时前
2026/5/27 生产事故复盘与整改方案
java
血小板要健康3 小时前
链表 阶段算法总结
java·数据结构·笔记·算法·leetcode·链表
坐吃山猪3 小时前
【多线程】CompletableFuture使用
java·开发语言·多线程
m0_587383003 小时前
点餐预约核销系统的架构脉络
java·架构·系统架构·需求分析
代码方舟4 小时前
O2O二手车交易平台B端车商管理后台:基于天远车信盟出险构建自动化车况评估网关
java·运维·人工智能·自动化
爱学堂IT分享4 小时前
图灵Java互联网架构师六期
java·开发语言