This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 223331 - Default open action does not know how to open PDF
Summary: Default open action does not know how to open PDF
Status: RESOLVED WORKSFORME
Alias: None
Product: utilities
Classification: Unclassified
Component: PDF (show other bugs)
Version: 7.3
Hardware: PC Linux
: P3 normal (vote)
Assignee: Jaroslav Havlin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-05 16:06 UTC by Jiri Kovalsky
Modified: 2013-03-01 11:25 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Message.log containing exception when opening PDF file (37.40 KB, text/x-log)
2013-03-01 11:05 UTC, Jiri Kovalsky
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Kovalsky 2012-12-05 16:06:55 UTC
Product Version: NetBeans IDE Dev (Build 201212050001)
Updates: Updates available
Java: 1.7.0_06; Java HotSpot(TM) Client VM 23.2-b09
Runtime: Java(TM) SE Runtime Environment 1.7.0_06-b24
System: Linux version 3.0.0-12-generic running on i386; UTF-8; cs_CZ (nb)
User directory: /home/cesilko/.netbeans/dev
Cache directory: /home/cesilko/.cache/netbeans/dev

Description:
============
Open action on PDF data node only asks user to specify command for external PDF viewer. This is a regression and a step backward though, because in NetBeans 7.2.1 this worked out of the box.

Steps to reproduce:
===================
1. Invoke "Windows > Favorites" from main menu.
2. Navigate to some folder containing PDF files.
3. Double click any PDF node.
4. "Select PDF Viewer" dialog pops up instead of opening the PDF externally automatically.
Comment 1 Jaroslav Havlin 2012-12-07 13:14:08 UTC
It works correctly for me.
Java Desktop API (java.awt.Desktop) is used to open PDF files.
The implementation has not been changed since NetBeans 7.2.
It seems that PDF Viewer is not correctly configured in your system.
What Linux distribution do you use?
Comment 2 Jiri Kovalsky 2012-12-07 13:58:22 UTC
I am on Linux Mint 12. However, I repeat that NetBeans 7.2.1 opens PDF files on the same system without any problems.
Comment 3 Jaroslav Havlin 2012-12-07 14:09:31 UTC
(In reply to comment #2)
> I am on Linux Mint 12. However, I repeat that NetBeans 7.2.1 opens PDF files on
> the same system without any problems.
Please, could you try it again, with 7.2.1 running on the same JDK as 7.3, and check IDE Logs if there is something useful?
Do you use KDE, Gnome 3, Gnome 2, XFCE or something else?
Thank you very much.
Comment 4 Jaroslav Havlin 2012-12-07 16:01:22 UTC
I've just checked XUbuntu 12.04 on OpenJDK 7 and it works fine.
I'll be able to test it with Ubuntu on Oracle JDK.  Unfortunately, I have currently no Mint installation, but I guess that standard Ubuntu with Unity should be very similar to Mint with Gnome.
Comment 5 Jaroslav Havlin 2012-12-10 09:44:48 UTC
> I'll be able to test it with Ubuntu (Unity) on Oracle JDK.
Works as expected, too.
Comment 6 Jaroslav Havlin 2012-12-17 09:26:34 UTC
> Please, could you try it again, with 7.2.1 running on the same JDK as 7.3, and
> check IDE Logs if there is something useful?
> Do you use KDE, Gnome 3, Gnome 2, XFCE or something else?
I haven't been able to reproduce the bug yet. Closing for now.
Please reopen if you can provide more information. Thank you.
Comment 7 Jiri Kovalsky 2013-01-31 11:43:50 UTC
So I checked this again and it's really strange. I tested 7.2.1 a 7.3 RC with JDK 7 Update 6 to 11 and found out that the problem is caused by Update 11. Both 7.2.1 and 7.3 RC open PDF files just fine if it's run on JDK 7 Update 10 or older. Can you please test it too Jardo? Thanks.
Comment 8 Jaroslav Havlin 2013-02-08 08:14:59 UTC
(In reply to comment #7)
> So I checked this again and it's really strange. I tested 7.2.1 a 7.3 RC with
> JDK 7 Update 6 to 11 and found out that the problem is caused by Update 11.
> Both 7.2.1 and 7.3 RC open PDF files just fine if it's run on JDK 7 Update 10
> or older. Can you please test it too Jardo? Thanks.
Thank you. I tried other JDKs, but I still cannot reproduce the bug.
I've just tested it on Ubuntu 12.04 LTS (Unity) with JDK 7u10, 7u11 and 7u13 (all 32 bit) and everything worked fine for me.
Comment 9 Jiri Kovalsky 2013-02-12 12:23:06 UTC
Can I help diagnose the problem somehow? What's the code executing the command? Is there some verbose NetBeans option that would give you more details? If you write a testing class with some debug logging I can run it on my configuration to help us understand what's going on.
Comment 10 Jiri Kovalsky 2013-02-12 12:24:43 UTC
BTW, my system is 64b.
Comment 11 Jaroslav Havlin 2013-02-12 16:26:38 UTC
> Is there some verbose NetBeans option that would give you more details?
No, but that's a good idea to log the exception, thanks.

The error occurs probably in Desktop.open(File). If it fails to open a file, it will now log error message and stack trace to the IDE Log.
http://hg.netbeans.org/core-main/rev/cebf2c7e6486
Comment 12 Quality Engineering 2013-02-14 02:20:27 UTC
Integrated into 'main-golden', will be available in build *201302132300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/cebf2c7e6486
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #223331: Log exception if java.awt.Desktop fails to open a PDF file
Comment 13 Jiri Kovalsky 2013-03-01 11:05:22 UTC
Created attachment 132058 [details]
Message.log containing exception when opening PDF file

The IDE indeed threw an exception. Does this help fix the problem?
Comment 14 Jiri Kovalsky 2013-03-01 11:07:56 UTC
You know what? It seems like a JDK issue, because the same IDE opens PDF files normally if JDK 7 Update 15 is used. Strange. :|
Comment 15 Jaroslav Havlin 2013-03-01 11:25:33 UTC
(In reply to comment #14)
> You know what? It seems like a JDK issue, because the same IDE opens PDF files
> normally if JDK 7 Update 15 is used. Strange. :|
Yes, it may a bug, or the Desktop API is not really supported by older JDKs on your system.

INFO [org.netbeans.modules.pdf.PDFOpenSupport]: java.awt.Desktop.open() failed.
java.lang.UnsupportedOperationException: Desktop API is not supported on 
                                         the current platform
	at java.awt.Desktop.getDesktop(Desktop.java:144)
[catch] at org.netbeans.modules.pdf.PDFOpenSupport.open(PDFOpenSupport.java:105)
	at org.openide.awt.ActionDefaultPerfomer.actionPerformed(
                                                  ActionDefaultPerfomer.java:70)

I would say that NetBeans IDE itself works correctly. It tries to use a service (Java Desktop API), and if it is not available, a fallback method (ask for path to PDF viewer) is used. So I think there is no better fix for this situation.

At least it's good news that it works fine with the latest JDK, it's a helpful information. Thank you for checking it.