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

}

}

相关推荐
Jelena1577958579213 小时前
电商运营分析数据比价接口实战:多平台价格监控与智能决策系统
java·大数据·数据库
神明不懂浪漫14 小时前
【第五章】Java中的继承与多态
java·开发语言
AI多Agent协作实战派16 小时前
AI多Agent协作系统实战(十七):凌晨4点,我的AI系统在“假装工作“——3个bug同时爆炸的5小时
java·前端·bug
gaolei_eit16 小时前
Java+Ai+vue
java·spring·maven
qq_25183645716 小时前
基于java Web 动漫视频网站毕业论文
java·开发语言·前端
LayZhangStrive16 小时前
JUC相关的函数、注解、变量杂记
java·面试·多线程·juc
未秃头的程序猿16 小时前
给公司做了个AI客服Agent,用的Spring AI 1.0,3天上线领导拍板了
java·后端·ai编程
曹牧16 小时前
Eclipse 批量文本替换
java·ide·eclipse
程序员清风16 小时前
OpenAI官方发布最新提示词技巧!
java·后端·面试
一只枫林16 小时前
MySQL内、外连接知识点汇总
java·前端·数据库