我有一个罐子里面包含另一个罐子,我的目标是从全局罐子里运行这个“内部罐子”。运行从另一个罐子的罐子
我有这种方法,其检索包含在所述罐子
private static String getRealPathFromResourceName(String fileName) throws IOException {
ClassLoader cl = Main.class.getClassLoader();
URL resource = cl.getResource(fileName);
String path = resource.getPath();
return path;
}
然后我运行jar的完整路径是:
public static boolean exportFullPeriod(CheckConfiguration checkConfig) throws IOException {
final String cmdLine = buildExportCommandLine(checkConfig);
try {
Process process = Runtime.getRuntime().exec(cmdLine);
....
} catch (
...
}
其中建立exportCommandLine构建使用先前的完整的命令行方法,全部输出为:
java -jar file:/C:/Users/xxx/target/module-backup-1.0.jar!/export-1.1.jar -dbUrl jdbc:mysql://localhost:3306/test -dbPassword test -dbUser test
我得到的错误是以下
Error: Unable to access jarfile file:/C:/Users/xxx/target/module-backup-1.0.jar!/export-1.1.jar
如何引用我的jar中的jar来调用它?
是你尝试执行依赖的jar tmp的项目吗?如果是,为什么不实际调用jar的main()? –
它不是一个依赖项,我将它作为资源添加 – Max
好吧。那为什么不把它作为一个库来添加呢? –