简体   繁体   中英

How to output a file from another non java programme into the resources folder of a java jar file

I have an R script that outputs html and dumps it in a directory of my choosing. I also have a java Swing application with a WebView component that allows me to see the html from within the Swing application.

This works OK on most computers but because the outputted html contains a base64 image, for some reason the image cannot be viewed from the Swing WebViewer on certain operating systems(although the rest of the html can-I can see the images on my mac but not on Windows 2003).

I think this is a problem relating to the security of a java programme accessing resources outside of the programme that maybe permissions are not set up for or something.

To simplify things I want to dump the html in resources that are local to the Swing application (ie in a resources folder) that would be contained within the deployed jar. How can I do this? Is this even possible?

Yes, this possible. This way you have to

  • Script: inserts the content within the jar file (root folder within the jar)
  • Swing: program has to be (re-)started
  • Swing: read file from within jar (eg with getResourceAsStream - method of the class loader)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM