FaqCliOpen

(Difference between revisions)
(Examples)
 
(One intermediate revision not shown)
Line 2: Line 2:
===Can I associate a file type with NetBeans to be able to open files of that type from File Explorer?===
===Can I associate a file type with NetBeans to be able to open files of that type from File Explorer?===
-
Yes, you can.
+
Yes, you can. Just pass the name of the file to be opened as the only argument. For example:
-
====NetBeans 6.0+====
+
netbeans MyFile.java
-
Just pass the name of the file to be opened as the only argument. For example:
+
The same command can be used to create an association for files of specific types in the file manager.
-
<pre>
+
-
  netbeans MyFile.java </pre>
+
-
The <tt>--open</tt> option described below works, too.
+
You can also use the explicit <tt>--open</tt> option for clarity, and pass more than one file; for example, on Unix:
-
====Older Releases====
+
find src -name \*.java -print0 | xargs -0 netbeans --open
-
You need to pass the file via the <tt>--open <filename></tt> option.
+
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.
-
You can start the NetBeans IDE and have it open a file you specify in the command line as an argument
+
In addition, you can specify the line at which the file should open (line numbers start at 1):
-
to the <tt>--open</tt> option. If there is an already running instance of the IDE, the file will simply open in this instance.
+
-
 
+
-
In addition, you can specify the line at which the file should open as <tt>--open <filename:line></tt> where
+
-
''line'' is the line number starting from 1.
+
-
 
+
-
The same command can be used to create an association for files of specific types in the file manager.
+
-
 
+
-
Note that the <tt>--open</tt> switch is mandatory. As of now, it is not possible specify the files to be opened as
+
-
a simple argument list. For example, <tt>'netbeans a.java'</tt> won't work.
+
-
 
+
-
--------
+
-
====Examples====
+
netbeans Something.java:55
-
* To start NetBeans and have it open ''a.java'':
+
To create an association for ''.java'' files in Windows File Explorer:
-
  <pre>
+
# In File Explorer, select '''Tools | Folder Options'''.
-
    netbeans a.java            (NetBeans 6.0+)
+
# Select the '''File Types''' tab.
-
    netbeans --open a.java      (NetBeans 4.0+) </pre>
+
# Find the Java file type or create one, if it doesn't exist yet.
-
* To start NetBeans and have it open file ''b.java'' at line 67:
+
# Click the '''Advanced''' button
-
  <pre>
+
# Create a new action called ''Open'' and specify the command like this:
-
    netbeans b.java:67          (NetBeans 6.0+)
+
"C:\Program Files\netbeans\bin\netbeans.exe" --open %1
-
    netbeans --open b.java:67  (NetBeans 4.0+)</pre>
+
-
* To create an association for ''.java'' files in Windows File Explorer:
+
-
## In File Explorer, select '''Tools | Folder Options'''.
+
-
## Select the '''File Types''' tab.
+
-
## Find the Java file type or create one, if it doesn't exist yet.
+
-
## Click the '''Advanced''' button
+
-
## Create a new action called ''Open'' and specify the command like this:
+
-
  <pre>
+
-
  "C:\Program Files\netbeans-4.1\bin\netbeans.exe" --open %1 </pre>
+
--------
--------
-
  Applies&nbsp;to: NetBeans 4.0, 4.1, 5.0, 5.5, 5.5.1, 6.x
+
Applies to: NetBeans 6.0+
-
  Platforms: All ''(file association registration may vary among platforms)''
+
Platforms: --open is available on all platforms. File association registration may vary among platforms (not confirmed for Windows 7).

Current revision as of 22:03, 13 December 2011

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