java - Runtime.getRuntime().exec 可以是类路径资源吗?

标签 java spring exec

这是我的代码

File file = ResourceUtils.getFile("classpath:run.sh");
String path = file.getAbsolutePath();

但是当我这样做时

Runtime.getRunTime().exec(path)

它抛出 FileNotFoundException

class path resource [run.sh] cannot be resolved to absolute file path because it 
  does not reside in the file system: 
  jar:file:/root/backend-2.1.2.RELEASE.jar!/BOOT-INF/classes!/run.sh

最佳答案

没有。您的操作系统不知道如何从存档运行应用程序。

关于java - Runtime.getRuntime().exec 可以是类路径资源吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54454080/

相关文章:

java - 如何在 Switch case 语句中使用范围检查

java - Java 桌面应用程序的安装程序

Java邮件API连接存储在本地服务器但未连接到开发服务器

java - Spring 与 JSON 前缀配置有关的问题

Linux awk 字符串执行变量

PHP:exec(svn commit) 不返回任何不工作的错误

java - XML 架构 : replacing imports with corresponding schema

java - ehcache hibernate二级缓存,hibernate自动驱逐

java - 关闭自动 View 分辨率 spring 4

php - exec() 在 PHP 中等待响应