我在netbeans中遇到java web start applet的问题。我无法从applet运行的地方(即服务器)获取需要访问的文件和图像的路径。基本上我在本地机器上使用图像来显示文件夹和pdf文件的图标,当我在非Web上下文中运行applet时,这很好用,但是尝试在服务器意义上使用它会导致失败。
以下是导致问题的代码:
company.readCompanyFile("C:\\Users\\Chris\\Desktop\\ArFile Clients\\" + companyName + "\\"
+ companyName + ".cmp");
这只是一个简单的缓冲读卡器,试图读取存储在此位置的文件。是否应将这些目录嵌套在程序根目录中的问题是:
C:\Users\Chris\Documents\NetBeansProjects\ArFile
反映我上面提供的信息的一个例子很棒
编辑:这是Applet提供的错误消息
BadFieldException[ The field <extension>href has an invalid value: C:\Users\Chris\Desktop\ArFile Clients,C:\Users\Chris\Desktop\ArFile Clients]
at com.sun.javaws.jnl.XMLUtils.getAttributeURL(Unknown Source)
at com.sun.javaws.jnl.XMLUtils.getRequiredURL(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.handleResourceElement(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.access$800(Unknown Source)
at com.sun.javaws.jnl.XMLFormat$2$1.visitElement(Unknown Source)
at com.sun.javaws.jnl.XMLUtils.visitChildrenElements(Unknown Source)
at com.sun.javaws.jnl.XMLFormat$2.visitElement(Unknown Source)
at com.sun.javaws.jnl.XMLUtils.visitElements(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.buildResourcesDesc(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptorFromCache(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptorFromCache(Unknown Source)
at sun.plugin2.applet.JNLP2Manager.initialize(Unknown Source)
at sun.plugin2.main.client.PluginMain.initManager(Unknown Source)
at sun.plugin2.main.client.PluginMain.access$200(Unknown Source)
at sun.plugin2.main.client.PluginMain$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Error while initializing manager: BadFieldException[ The field <extension>href has an invalid value: C:\Users\Chris\Desktop\ArFile Clients,C:\Users\Chris\Desktop\ArFile Clients], bail out
BadFieldException[ The field <extension>href has an invalid value: C:\Users\Chris\Desktop\ArFile Clients,C:\Users\Chris\Desktop\ArFile Clients]
at com.sun.javaws.jnl.XMLUtils.getAttributeURL(Unknown Source)
at com.sun.javaws.jnl.XMLUtils.getRequiredURL(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.handleResourceElement(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.access$800(Unknown Source)
at com.sun.javaws.jnl.XMLFormat$2$1.visitElement(Unknown Source)
at com.sun.javaws.jnl.XMLUtils.visitChildrenElements(Unknown Source)
at com.sun.javaws.jnl.XMLFormat$2.visitElement(Unknown Source)
at com.sun.javaws.jnl.XMLUtils.visitElements(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.buildResourcesDesc(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptorFromCache(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptorFromCache(Unknown Source)
at sun.plugin2.applet.JNLP2Manager.initialize(Unknown Source)
at sun.plugin2.main.client.PluginMain.initManager(Unknown Source)
at sun.plugin2.main.client.PluginMain.access$200(Unknown Source)
at sun.plugin2.main.client.PluginMain$2.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Error while initializing manager: BadFieldException[ The field <extension>href has an invalid value: C:\Users\Chris\Desktop\ArFile Clients,C:\Users\Chris\Desktop\ArFile Clients], bail out
答案 0 :(得分:0)
我使用的是相对文件路径,这在Java Web Start上下文中不起作用,必须使用绝对路径才能使应用程序正常运行。