Can I associate a file type with NetBeans to be able to open files of that type from File Explorer?

Yes, you can. Just pass the name of the file to be opened as the only argument. For example:

netbeans MyFile.java

The same command can be used to create an association for files of specific types in the file manager.

You can also use the explicit --open option for clarity, and pass more than one file; for example, on Unix:

find src -name \*.java -print0 | xargs -0 netbeans --open

If there is an instance of the IDE already running, the file will simply open in this instance and the command will exit. You may need to pass the --userdir option to match the user directory of the running IDE.

In addition, you can specify the line at which the file should open (line numbers start at 1):

netbeans Something.java:55

To create an association for .java files in Windows File Explorer:

  1. In File Explorer, select Tools | Folder Options.
  2. Select the File Types tab.
  3. Find the Java file type or create one, if it doesn't exist yet.
  4. Click the Advanced button
  5. Create a new action called Open and specify the command like this:
"C:\Program Files\netbeans\bin\netbeans.exe" --open %1

Applies to: NetBeans 6.0+

Platforms: --open is available on all platforms. File association registration may vary among platforms (not confirmed for Windows 7).

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo