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 138943 - Can not open files by double clicking in the OS file manager
Summary: Can not open files by double clicking in the OS file manager
Alias: None
Product: platform
Classification: Unclassified
Component: Launchers&CLI (show other bugs)
Version: 6.x
Hardware: All Mac OS X
: P1 blocker with 7 votes (vote)
Assignee: Libor Fischmeistr
: 187438 191708 246941 248009 (view as bug list)
Depends on: 235558
Blocks: 137169
  Show dependency tree
Reported: 2008-07-03 12:52 UTC by Petr Jiricka
Modified: 2017-02-25 12:32 UTC (History)
11 users (show)

See Also:
Exception Reporter:

patch proposed by Tim (3.04 KB, text/plain)
2008-07-04 14:58 UTC, dlipin
my changes to the applemenu module (9.07 KB, patch)
2008-09-30 12:46 UTC, Milos Kleint
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2008-07-03 12:52:34 UTC
1. Use a file manager application (e.g. Finder on Mac OS X) to locate a text file, e.g. THIRDPARTYLICENSE.txt from the
NetBeans installation.
2. Right-click the file and choose Open With -> Other...
3. Change the "Enable" combo box to "All Applications"
4. Browse the NetBeans application, e.g. "NetBeans"
5. Click Open
=> NetBeans is started, but the file is not opened in NetBeans

Reproduced on Mac OS X, but the same problem may be present on Windows and Linux too (can anyone confirm?).
Comment 1 dlipin 2008-07-03 13:17:14 UTC
I cannot reproduce it on Windows and Linux (old FC4) so likely MacOSX-specific.
Comment 2 dlipin 2008-07-04 11:18:51 UTC
CC-ing Tim. He send me the e-mail with the following info (just for the record):

It looks like handleOpenFile() is wrong - the best it could do now would be to cause a file chooser to open.
A quick look at the code for handleOpenFile() shows it to be wrong - it would just open a file chooser if it did 
anything at all.

Anyway, here's what handleOpenFile() should probably look like - I haven't tested it though.

Things to check and tune:
 - can ApplicationEvent.getFilename() ever return a list of files?
 - does handleOpenApplication() perform the same role as handleOpenFile() if no copy of NB was running?  If so, needs 
to be handled, including making sure it is not really run until all modules are loaded

Anyway, the attached patch should give it at least a shot at working.  However, I see:

But if we ever want NB to be on the Open With menu, that's going to be a bit of a challenge - see:
"These events are sent only if the bound application has file types listed in the Info.plist entries Document Types or 

I suspect the event may still be sent if you choose Open With -> Other -> NetBeans.

To do this semi-right, the build process that creates the NB application bundle would need to run some sort of custom 
Ant task that finds all file extensions that the copy of NetBeans it is bundling can read, and generate the Info.plist 
that lists those file types in the metadata that describes NB to Mac OS.

Doable, but won't help for any newly downloaded modules - you need to be superuser to edit the Info.plist of an 
installed application.

Of course, hard-coding a set of file types we know we want to accept would be a start. 
Comment 3 dlipin 2008-07-04 14:58:16 UTC
Created attachment 63948 [details]
patch proposed by Tim
Comment 4 _ tboudreau 2008-07-04 16:34:54 UTC
Caveat:  whether in handleOpenFile() or in handleOpenApplication() (reading the docs further, probably handleOpenFile() is what will be called) when a user 
double clicks a file in Finder and chooses Open With -> ...NetBeans, the documentation mentions that the event will be sent "after AWT is initialized".  That 
will be way too early in the startup sequence for the applemenu module to have registered its handler.

So my guess is, doing this without an already-running copy of NetBeans probably means adding the ApplicationListener much earlier in startup and trying to 
open the file after the main window is initialized.
Comment 5 _ tboudreau 2008-07-04 16:39:10 UTC
Also apropos:

Comment 6 Milan Kubec 2008-07-11 16:57:50 UTC
Tim how can I test the fix? 'Open with' action on MacOSX only allows to select and I don't know how to create such launcher from sources. Is 
it even possible to debug something launched via .app launcher?
Comment 7 _ tboudreau 2008-07-11 19:17:45 UTC
> I don't know how to create such launcher from sources

I'm not sure what you mean - could you clarify?

In case I was being unclear:  Basically, any Mac OS X application directory contains a file Contents/Info.plist

That file can contain a static list of file types the application can open.  

Right now NetBeans' Info.plist does not contain any data about file types it handles, so NetBeans only appears on the Open With menu.

To put it on the Open menu, we would want to generate a list of file types NB handles when the Mac application bundle is generated.

Does that help?
Comment 8 Milan Kubec 2008-07-11 20:53:40 UTC
> I'm not sure what you mean - could you clarify?

I mean that if I invoke Open With I can only select application, but IDE built from sources (with the fix) is not MacOSX application, so I cannot test it.

I assume that the file Info.plist needs to be generated during IDE installation by installer.

Comment 9 _ tboudreau 2008-07-14 02:50:23 UTC
Run the Ant script in installer/mac to build the mac application structure (I see there is installer/mac/newbuild - not sure what that is, maybe the thing that 
does the new mpkg installers?)
Comment 10 dlipin 2008-07-18 08:10:13 UTC
Both ant scripts in installer/mac (not used at the moment, not up-to-date) and installer/mac/newbuild will build the 
installers (wrapped in .dmg), neither will build the .app structure.
The Info.plist that is used now (need some token replacement), is located at installer/mac/newbuild/netBeans.
Comment 11 Milos Kleint 2008-09-30 12:37:17 UTC
I have added the following snippet to the Info.plist file inside the


After some moving around of the (probably for apple to recognize the change), I was able to select netbeans
as the editor for a java file in the finder.
HOWEVER the our listener's ApplicationListener.handleOpenFile (ApplicationEvent e) was never called by the environment.
I've tried moving the listener registration to ModuleInstall.validate() which is the most early point in startup a
module can execute it's code. I got the ApplicationListener.handleOpenApplication (ApplicationEvent e) method called
(thus the listener is correctly registered) but the handleOpenFile() method was never called.

-> I might have done something wrong, but the finder environment behaves as if it's setup correctly.

See for description of CFBundleDocumentTypes element in Info.plist

See for a list of default content types

Reassigning to installer, as we need the entries in the Info.plist first as a prerequisite to fix the (possible) bug in
our code that opens the file badly. Right now (without the Info.plist content) our code is not called at all.

I'm running the latest 1.5.0_16 java.
Comment 12 Milos Kleint 2008-09-30 12:46:09 UTC
Created attachment 70888 [details]
my changes to the applemenu module
Comment 13 dlipin 2008-09-30 16:20:00 UTC
I`ve made the changed in installer to pick-up "" type (.sh and .command files).
(please let me know it is not enough)
.sh files editing support is included in the ideX cluster and therefore is available in every NetBeans distro.

I thought of - but it will not work in non-Java distros and who knows what bugs it could introduce.

Passing back to core.

PS. As the long term solution we should dynamically add different CFBundleTypeName keys depending on the packs selected 
in installer. To do that we should have the full list of file extensions that we want to register and which module 
(better - cluster) is the editor support for that file type located at.
Comment 14 Quality Engineering 2008-10-01 05:59:27 UTC
Integrated into 'main-golden', will be available in build *200810010201* on (upload may still be in progress)
User: Dmitry Lipin <>
Log: Temporary workaround for #138943 : register .sh files for the .app
Comment 15 _ tboudreau 2008-10-02 23:25:21 UTC
> but the handleOpenFile() method was never called

Probably the best place to ask about this is on - or I can put you in touch with someone from Apple.
Comment 16 Milos Kleint 2008-10-06 07:53:32 UTC
dlipin: with your changes, the sh files have netbeans in the preferred list for opening. That's good. However I'm not
sure we should be shipping with the change in 6.5, especially if the file opening doesn't actually work and is only
setup for sh files.

I've asked on java-dev@apple about the problem.
Comment 17 Milos Kleint 2008-10-08 07:22:38 UTC
according to this message
the fact that we are using a shell script to start netbeans prohibits us from opening the file from finder. The shell
script blocks the OS from calling the java event callback.

closing as wontfix. 
Comment 18 Petr Jiricka 2009-09-24 11:02:45 UTC
Another user request for this feature:
Comment 19 dlipin 2010-09-15 17:58:35 UTC
*** Bug 187438 has been marked as a duplicate of this bug. ***
Comment 20 letssurf 2011-07-08 14:49:02 UTC
Is this still not possible?
Comment 21 toxikman 2011-08-13 06:54:59 UTC
I agree, it's kind of odd that you can't open a simple file from the Finder and have NetBeans open it? Every other IDE/Text-Editor on the planet has this simple functionality. With NetBeans, you are forced to either use File->Open or Drag'n'Drop the file.

Can someone devise a simple work-around, such as writing a temporary file that you look for at startup? Something like "HeyNetBeans-OnceYouHaveLoadedThenOpenFileXXX"   The startup sh script could generate that file based on what the Finder wishes to open, assuming it's true that the launched IDE can't get at this information from the OS.
Comment 22 bluescrubbie 2012-10-15 23:30:02 UTC
Another year gone by - is netbeans still technically unable to open files from Finder?
Comment 23 bluescrubbie 2012-10-15 23:30:22 UTC
Another year gone by - is netbeans still technically unable to open files from Finder?
Comment 24 marvi 2012-10-31 09:07:05 UTC
Anyone working on this?
Comment 25 Jiri Rechtacek 2012-11-01 04:16:49 UTC
*** Bug 191708 has been marked as a duplicate of this bug. ***
Comment 26 Jiri Rechtacek 2012-11-01 04:21:27 UTC
IFAIK the current launcher for Mac doesn't allow to make this association. Any patch/hints are welcome.
Comment 27 jorahood 2013-04-03 02:11:47 UTC
Just adding another comment that some solution to this would be very much appreciated.
Comment 28 eleftrik 2013-04-04 08:03:21 UTC
This bug has been reported almost 5 years ago, and AFAIK there is still no solution.
I think this is a basic functionality for an IDE/editor.
I gave up. Moved to another IDE for Mac OS. Sorry for my useless comment.
Comment 29 bunam 2014-08-29 08:31:36 UTC
This AppleScript do the job :
Comment 30 Jaroslav Havlin 2014-09-12 13:07:06 UTC
*** Bug 246941 has been marked as a duplicate of this bug. ***
Comment 31 Jaroslav Havlin 2014-11-14 11:06:33 UTC
*** Bug 248009 has been marked as a duplicate of this bug. ***
Comment 32 tareqtms 2015-07-10 05:23:25 UTC
Having the same issue in my new Mac OS X Yosemite 10.10.4 and Netbeans version 8.0.2
Comment 33 TheKarateKid 2015-09-28 19:45:12 UTC
This still does not work on OS X Yosemite 10.10.5 and Netbeans 8.0.2. Do the developers have any plans to fix this in Netbeans 8.1 or a future version?
Comment 34 sgd5026 2016-05-12 23:36:27 UTC
This still does not work on OS X Yosemite 10.10.5 and Netbeans 8.1
Comment 35 schrulli 2017-02-25 12:32:30 UTC
This still does not work on MacOS Sierra and Netbeans 8.2