2011-01-24 19 views
5

Ứng dụng Java trong nhà của chúng tôi khởi chạy nhiều URL http khác nhau, bao gồm URL tới trang web, tài liệu MS Word, tài liệu MS Excel, tệp PDF, v.v.Adobe Acrobat chặn mọi URL từ cuộc gọi đến BasicService.showDocument() trong java

Trên hơn 50 máy, URL khởi chạy hoạt động tốt và ứng dụng chính xác mở trang/tài liệu đã cho chính xác. Tuy nhiên, trên một máy pesky Adobe Acrobat đang cố gắng mở mọi URL (bất kể mục tiêu đó có phải là pdf hay không) và không (ngay cả trên tài liệu pdf) với:

Đã xảy ra lỗi khi mở tài liệu này . Tên tệp, tên thư mục hoặc cú pháp nhãn khối lượng không chính xác.

Mã để khởi động các URL là:

URL url = new URL("http://www.example.com"); 
BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService"); 
boolean worked = bs.showDocument(url); 

Biến worked là đúng sau khi cuộc gọi.

điểm khác có thể hữu ích:

  • Ứng dụng này chạy trong Java Web Start.
  • Một applet chạy trên cùng một máy có thể mở URL chính xác bằng cách sử dụng AppletContext.showDocument()
  • Nhập URL vào hộp thoại "Chạy ..." của Windows khởi chạy URL chính xác.
  • Chúng tôi đã cài đặt lại cả JRE và Adobe Acrobat.

Cảm ơn bạn trước lời khuyên/trợ giúp bạn có thể cung cấp.

Cập nhật:

Mã debug sau xuất ra như sau:

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> 
[email protected] 
bs.getCodeBase():http://xxx.xxxxxx.com:8080/ 
bs.isOffline():false 
bs.isWebBrowserSupported():true 
bs.showDocument:true 

Trả lời

1

Các bạn đã giải quyết vấn đề này chưa? Nếu không, bạn có thể thử những điều sau đây không?

FileOpenService fos = (FileOpenService)ServiceManager.lookup("javax.jnlp.FileOpenService"); 
+0

Cảm ơn. Tôi đã sửa bài viết gốc của tôi ở trên ... nó xuất hiện như thể FileOpenService hiện diện ...? – cagcowboy

Các vấn đề liên quan