JavaFX加载外部资源问题

发布于 2024-08-27 18:45:26 字数 174 浏览 1 评论 0原文

我在 Netbeans 6.8 IDE 中编写了小型 JavaFX Applet。如果小程序在我的计算机上运行,​​则一切正常。但是,当我将小程序(并编辑包含更改的服务器路径的 JNLP 文件)放入服务器时,它不会从服务器文本文件加载任何数据。路径是正确的 - 我看了很多次 - 没问题。它也不会加载具有外部 URL 的图像。怎么了?

I've coded small JavaFX Applet in Netbeans 6.8 IDE. Everything works fine if the applet runs on my computer. But when I put the applet (and edited JNLP files containing changed paths to server) into server, it doesn't load any data from an server text file. Paths are correct - i look at it many times - they are ok. It also doesn't load images with external urls. What is wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

追我者格杀勿论 2024-09-03 18:45:26

没有看到你的代码,所以我会猜测。如果您的资源未捆绑在 JAR 文件中并且您使用 file:// 来访问它,那么您将需要对您的小程序进行签名。在 NetBeans 上,右键单击项目节点 ->属性->应用。选择自签名。

如果您不想签署您的小程序,请以 REST 方式访问您的资源。使用 HttpRequest。

如果它在客户端计算机上,请考虑使用 JNLP API,如下所示。

FileOpenService fos = (FileOpenService)ServiceManager
        .lookup(“javax.jnlp.FileOpenService”);

//Open dialog pops up
FileContent fc = fos.openFileDialog(null, null);

诊断问题的最佳方法是打开Java控制台并查看是否有任何异常。运行 $JAVA_HOME/bin/ControlPanel ->高级-> Java 控制台 ->显示控制台

Haven't seen your code so I'm going to make a guess. If your resource is not bundled in your JAR file and you are using file:// to access it, then you will need to sign your applet. On NetBeans, right click on project node -> properties -> application. Select self signed.

If you don't want to sign your applet, then access your resource as REST. Use the HttpRequest.

If it is on the client machine, consider using JNLP APIs like so.

FileOpenService fos = (FileOpenService)ServiceManager
        .lookup(“javax.jnlp.FileOpenService”);

//Open dialog pops up
FileContent fc = fos.openFileDialog(null, null);

The best way to diagnose the problem is to open the Java Console and see if there are any exceptions. Run $JAVA_HOME/bin/ControlPanel -> Advanced -> Java Console -> Show Console

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文