开发者

Access bundled Java file from outside the JVM

开发者 https://www.devze.com 2023-04-04 17:19 出处:网络
Is it possible to access a bundled Java file from outside the JVM?My particular issue is that I have Ruby scripts bundled with my application that I need to execute from the command line.

Is it possible to access a bundled Java file from outside the JVM? My particular issue is that I have Ruby scripts bundled with my application that I need to execute from the command line.

The Ruby scripts are located at src/main/resources, and to execute them I am using a third party exe in Windows where the final command looks something like: custom_ruby.exe -script PATH_TO_SCRIPT

So, I need to get a file system path开发者_开发百科 to a bundled Java resource. Is this even possible? If not I am planning to read the Ruby Script in Java, and simply write it to a temp directory. If there is a more elegant solution I'd like to know.

Thanks.


You are looking for Class.getResource() and Class.getResourceAsStream(). Checkout an example here.

0

精彩评论

暂无评论...
验证码 换一张
取 消