使用命令行参数创建 jar 文件后打开 jar 文件时未找到文件异常
问题陈述:
我有一个 J2ME 应用程序,并且有一个单独的 struts 程序正在运行。该程序会自动更改 J2ME 应用程序的源代码,然后构建它、预先验证它,然后使用命令行参数打包它。为了实现这一切,我在程序中使用了“Runtime.getRuntime().exec”。问题是,如果我在执行打包命令之前引入一秒的延迟,仍然会形成 jar 文件,但使用命令“DataInputStream in = new DataInputStream(new FileInputStream(f));”访问 jar 文件。给我文件未找到异常。 “f”是 jar 文件的路径,我已经使用“f.getCanonicalPath()”检查了它是否是正确的路径。
我不知道问题是什么。请帮我。我先谢谢你了。
The problem statement:
I have a J2ME app and i have a separate struts program running. The program automatically changes the source of the J2ME app an then builds it, pre-verify it, and then package it using command line arguments. To achieve all this i have used "Runtime.getRuntime().exec" in my program. Problem is that if i introduce a delay of one sec before the command for packaging is executed, the jar file is still formed BUT accessing the jar file using the command "DataInputStream in = new DataInputStream(new FileInputStream(f));" gives me File Not found exception. "f" is the path to the jar file and i have checked it using "f.getCanonicalPath()" that its the right path.
I don know what the problem is. Please help me. I thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否在访问 jar 文件之前等待由
Runtime.exec()
生成的进程完成?例如,您可以使用 Process.waitFor() 来停止线程的执行。Are you waiting for the Process spawned by
Runtime.exec()
to complete before accessing the jar file? You can useProcess.waitFor()
for instance to halt the execution of your thread.