简体   繁体   English

将文本文件写入罐子

[英]Writing A Text File To A Jar

I'm writing a program which 'builds' another. 我正在编写一个“构建”另一个程序。 I plan to save the settings insite the generated jar file, but am having some trouble with writing to an external jar. 我计划将设置保存到生成的jar文件中,但是在写入外部jar时遇到了一些麻烦。 Any help is appreciated. 任何帮助表示赞赏。

A jar is just a zip file so all you have to do is zip up your files and name the zip with a .jar extension. 一个jar只是一个zip文件,因此您要做的就是压缩文件并以.jar扩展名命名该zip。

One handy library to create jar archives is Shrinkwrap which allows you to put classes, resources, etc into jar files using a Java API Shrinkwrap是创建JAR存档的一个便捷库,它允许您使用Java API将类,资源等放入JAR文件中

A better solution would be to create a second jar, and write your own ClassLoader to load classes from that jar. 更好的解决方案是创建第二个jar,然后编写自己的ClassLoader从该jar加载类。 A kind of plugin mechanism. 一种插件机制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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