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

}

}

相关推荐
她的男孩4 小时前
Spring Boot 接 Flowable 工作流:用 3 个注解搭一个请假审批流程
java·后端·架构
荣码6 小时前
LLM结构化输出:让AI返回JSON而不是废话,我踩了4个坑
java·python
plainGeekDev7 小时前
Gson → kotlinx.serialization
android·java·kotlin
小bo波16 小时前
Java Swing 图形用户界面实验 —— 从算术练习到游戏开发的完整实践
java·课程设计·gui·游戏开发·扫雷·swing
咖啡八杯17 小时前
GoF设计模式——备忘录模式
java·后端·spring·设计模式
SamDeepThinking1 天前
裁掉那个差程序员后,给你看团队里高手的代码:这个习惯,希望你有
java·后端·程序员
朕瞧着你甚好1 天前
技术雷达 & Java 集成评估报告 — Apache Tika 3.3.1
java·ai编程
MacroZheng1 天前
短短几天,暴涨2.8万Star!又一款编程神器开源!
java·人工智能·后端