文件操作在 Java Web Start 中不起作用
我构建了这个处理文件的程序。因为我是为朋友制作的,所以我将其制作成 Java Web Start 应用程序,并配有 JNLP 文件。
当我在没有 JNLP 的情况下通过 ANT (netbeans) 启动应用程序时,它工作得很好。但是,当通过 JNLP(甚至通过 netbeans)启动时,本应执行所需操作的按钮却什么也不做(它只是保持在“单击”模式,直到您将鼠标悬停在远离它的位置)。
我花了几个小时试图找出问题所在,但没有运气。
这是有问题的方法:
public void copy(String path1, String path2) throws IOException {
File inputWorkbook = new File(inputFile);
Path in = Paths.get(path1);
Path out = Paths.get(path2);
Workbook w;
try {
w = Workbook.getWorkbook(inputWorkbook);
.
.
.
如果我不尝试对 inputWorkbook 文件执行任何操作,则一切正常。一旦我尝试对其执行任何类型的方法(例如 w = Workbook.getWorkbook(inputWorkbook),甚至 inputWorkbook.exsists();),就会出现问题。它甚至不会抛出异常,它只是不执行任何操作...同样,该问题仅在通过 JNLP 文件启动程序时出现。
我希望我能够解释这个问题......我是编程新手。
谢谢你!!!
亚当
I built this program that works with files. Since I made it for a friend, I made it into a Java Web Start app, complete with a JNLP file.
When I launch the app through an ANT (netbeans) without the JNLP, it works just fine. But when launched through the JNLP (even through netbeans), the button that is supposed to perform the required actions instead does nothing (it just stays in "clicked" mode until you hover away from it).
I spent hours trying to figure out the problem, but no luck.
Here is the problematic method:
public void copy(String path1, String path2) throws IOException {
File inputWorkbook = new File(inputFile);
Path in = Paths.get(path1);
Path out = Paths.get(path2);
Workbook w;
try {
w = Workbook.getWorkbook(inputWorkbook);
.
.
.
If I don't attempt to do anything with the inputWorkbook file, everything works ok. As soon as I attempt ANY sort of method on it (such as w = Workbook.getWorkbook(inputWorkbook), or even inputWorkbook.exsists();) , the problem occurs. It won't even throw an exception, it just does nothing... Again, the problem only occurs when the program is launched through the JNLP file.
I hope I managed to explain the problem... I'm new to programming.
Thank you!!!
Adam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Webstart 应用程序在安全沙箱中运行,防止访问文件系统。您需要对 har 进行数字签名才能访问文件系统,或者使用文件打开 api。请参阅 http://download.oracle。 com/javase/6/docs/technotes/guides/javaws/developersguide/faq.html#302 和 http://download.oracle.com/javase /6/docs/technotes/guides/javaws/developersguide/examples.html#FileOpenService 了解更多信息。
Webstart applications run in a security sandbox which prevents the to access the file system. You need to digitally sign your har to gain access to the file system, or use the file open api. See http://download.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/faq.html#302 and http://download.oracle.com/javase/6/docs/technotes/guides/javaws/developersguide/examples.html#FileOpenService for more information.