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.
精彩评论