Netbeans 插件在调试时工作正常,但在将插件安装到 IDE 时无法工作
我目前正在为 Netbeans 6.9.1 开发一个 Java 插件,使用 Apache POI api 与 Microsoft 文档进行交互,该文档有两个函数,第一个函数从属性文本文件中获取数据并创建一个包含该数据的 excel 电子表格(.xlsx),第二部分从电子表格中获取文本并将其添加到属性文本文件中。
当我在调试器中运行代码时,这两个功能都运行良好。文件按照预期创建和编辑,但是当我从项目创建 NBM 并安装插件时遇到了问题。导入(从 .xlsx 到 .txt)不会更改文本文件的内容。我在代码中多次检查了变量,以确保它们没有任何问题,并且一切都正常。导出(.txt 到 .xlsx)在插件中工作正常,所以我不确定到底发生了什么。当我开始导入时,它会完成这些步骤,但没有任何内容被更改或写入最终文件。
我对 Netbeans 还很陌生,所以我不确定调试器与影响程序行为的实际插件是否存在重大差异。任何帮助
I am currently working on a Java plugin for Netbeans 6.9.1 using the Apache POI api for interfacing with Microsoft documents that has two functions, the first takes data from a properties text file and creates an excel spreadsheet(.xlsx) containing that data, and the second part takes text from a spreadsheet and adds it to a properties text file.
When I run the code in the debugger both of the functions work great. The files get created and edited as they are supposed to, but I ran into problems when I created the NBM from the project and installed the plugin. The import (from .xlsx to .txt) does not do change the contents of the text file. I have checked variables at various times in the code to make sure there's nothing wrong with them there and everything was as it should. The export (.txt to .xlsx) works fine in the plugin, so I'm not sure exactly what's going on. When I start the import it goes through the steps, but nothing ever gets changed or written to the final files.
I'm pretty new to Netbeans so I'm not sure if there is a major difference from debugger to the actual plugin that is affecting how the program acts. Any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是创建一个要写入的临时文件。在调试器中,它写入项目文件夹,而当它作为插件安装时,它会在 Program Files 中创建临时文件。一旦在该目录中创建文件,Windows 就不允许程序获取该文件,因此我将其更改为在本地应用程序数据中创建文件。
很高兴它终于起作用了,在这样一个简单的修复上浪费了很多时间,希望这可以帮助将来的其他人。
The problem was creating a temporary file to write to. In the debugger it wrote to the projects folder, whereas when it was installed as a plugin it was creating the temporary file in Program Files. Windows wasn't letting the program get at the file once it was created in that directory so I changed it to create the file in Local App Data instead.
Glad that it's finally working, wasted a lot of time on such a simple fix, hope this can help someone else in the future.