在运行时在 jar 中添加文件 [英] Add files in jar during runtime

查看:38
本文介绍了在运行时在 jar 中添加文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

项目是创建exe文件.如果我们运行 exe 文件,它将打开一个管理页面(在 Swing 中设计),该页面包含浏览按钮、最大安装、最大安装系统和创建构建,同时单击浏览按钮我们需要从系统和该文件中选择一个 exe 文件需要将其保存在 jar 文件的一个文件夹中.maxinstall, max install sys 值存储在 SQL lite 数据库中.此管理页面将仅首次打开,以从管理员处获取条件.接下来,如果我们运行 exe 文件,它必须检查 maxinstall 和所有参数,然后安装所选的 exe 文件.

Project is to create exe file. If we run exe file it will open one admin page (designed in Swing) that page contains browse button, max install, max install sys, and create build, while click the browse button we need to select one exe file from system and that file need to save it inside one folder of jar file. The maxinstall, max install sys value is stored in SQL lite database. This admin page will open for first time only,to get condition from admin. Next if we run the exe file it must check maxinstall and all parameter and then install that selected exe file.

我的问题是,我从我的 java 程序创建了 jar.每次运行 jar 时,管理页面只打开(即)数据库文件在 jar 内没有更新,但它在 eclipse 中工作正常.之后我需要创建 jar 到 exe.

My problem is, I created jar from my java program. While running the jar each time, the admin page only opening (i.e) the database file is not updated inside jar, but its works fine in eclipse. After that I need to create jar to exe.

推荐答案

一旦创建了可执行文件 .jar,它将被锁定".如果您将更多文件添加到锁定的 .jar.jar 本身在运行时不会在内部识别这些文件.因此,更好的方法是提取您的依赖 .jar,然后将其添加到包含您需要的新文件的新的、可执行的 .jar 中.然后继续运行这个新的 .jar.

Once an executable .jar is created it will be "locked". I you add more files to a locked .jar, those files will not be recognized internally by the .jar itself at runtime. So, the better approach is to extract your dependent .jar and then add it to a new, executible .jar containing the new file(s) that you need. Then moving forward you can run this new .jar.

这篇关于在运行时在 jar 中添加文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆