Our In-House Java application launches various http URLs at various times, including URLs to web-pages, MS Word documents, MS Excel documents, PDF files etc.
On over 50+ machines the URL launching works fine and the correct application opens the given page/document correctly. However, on one pesky machine Adobe Acrobat is attempting to open every URL (regardless of whether the target is a pdf or not), and failing (even on pdf documents) with:
There was an error opening this document. The filename, directory name, or volume label syntax is incorrect.
The code to launch the URLs is:
URL url = new URL("http://www.example.com");
BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
boolean worked = bs.showDocument(url);
The worked
variable is true after the call.
Other points that may be helpful:
AppletContext.showDocument()
Thanks in advance for any advice/help you can offer.
Update:
The following debug code produces the following output:
String[] services = ServiceManager.getServiceNames();
if(services!=null) {
for(int i=0;i<services.length;i++) {
System.out.println("Available Service: "+services[i]);
}
}
BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
System.out.println(url);
System.out.println(bs);
System.out.println("bs.getCodeBase():"+bs.getCodeBase());
System.out.println("bs.isOffline():"+bs.isOffline());
System.out.println("bs.isWebBrowserSupported():"+bs.isWebBrowserSupported());
boolean worked = bs.showDocument(url);
System.out.println("bs.showDocument:"+worked);
} catch(UnavailableServiceException ue) {
System.out.println("UnavailableServiceException thrown");
ue.printStackTrace();
}
Available Service: javax.jnlp.BasicService
Available Service: javax.jnlp.FileOpenService
Available Service: javax.jnlp.FileSaveService
Available Service: javax.jnlp.DownloadService
Available Service: javax.jnlp.ClipboardService
Available Service: javax.jnlp.PersistenceService
Available Service: javax.jnlp.PrintService
Available Service: javax.jnlp.ExtendedService
Available Service: javax.jnlp.SingleInstanceService
http://<snip>
com.sun.jnlp.BasicServiceImpl@bbb8b5
bs.getCodeBase():http://xxx.xxxxxx.com:8080/
bs.isOffline():false
bs.isWebBrowserSupported():true
bs.showDocument:true
Have you solved this problem yet? If not, could you try the following?
FileOpenService fos = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With