Im having an issue when im trying to read in a text file while using a JApplet and Java Web Start, basically I have a file with a users data in it which I wish to read in. The text file is stored on the web server. Here is the code:
company.readCompanyFile("file:///C:/Users/Chris/Desktop/ArFile Clients/" + companyName + "/"
+ companyName + ".cmp");
and the readCompanyFile function is:
public void readCompanyFile(String cname)
{
try
{
BufferedReader br = new BufferedReader(new FileReader(cname));
name = br.readLine();
quota = Float.parseFloat(br.readLine());
String s;
while ((s = br.readLine()) != null)
{
String[] parts = s.split(":");
metadataFields.add(parts);
}
br.close();
}
catch(IOException e)
{
System.out.println("File does not exist, or has invalid format");
}
}
Which throws the following error when attempting to launch via java web start
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
The text file is stored on the web server.
... whereas the applet runs on the client computer. How is it going to read the file?
You have to make it accessible over the network, for example by HTTP (put it next to the applet on your server).
Also, that stacktrace does not seem to have anything to do with your code. It looks like Webstart failed to parse the deployment descriptor (probably also because of referencing files on the server's disk).