-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.java
More file actions
42 lines (35 loc) · 1.38 KB
/
run.java
File metadata and controls
42 lines (35 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 21
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
public class run {
public static void main(String[] args) throws Exception {
// Find the latest MCP JAR in target directory
Path targetDir = Paths.get("mcp/target");
if (!Files.exists(targetDir)) {
System.err.println("Target directory not found. Please run 'mvn clean install' first.");
System.exit(1);
}
Path jarFile = Files.list(targetDir)
.filter(p -> p.toString().endsWith(".jar") && !p.toString().contains("original"))
.filter(p -> p.toString().contains("mcp-"))
.findFirst()
.orElseThrow(() -> new RuntimeException("MCP JAR not found in target directory"));
System.out.println("Running Spring Vision MCP Server with JAR: " + jarFile);
// Build the command to run the JAR
String[] cmd = new String[args.length + 3];
cmd[0] = "java";
cmd[1] = "-jar";
cmd[2] = jarFile.toString();
System.arraycopy(args, 0, cmd, 3, args.length);
// Execute the command
ProcessBuilder pb = new ProcessBuilder(cmd);
pb.inheritIO();
Process process = pb.start();
int exitCode = process.waitFor();
System.exit(exitCode);
}
}