Opening a File From the Command Line
By divas on Aug 29, 2007
I learned a neat trick in the email@example.com mailing list this week, one that I wish I had discovered long ago -- how to open a file in the Netbeans editing area from the command line, even if the file is not in an opened project.
Make sure that the NetBeans bin directory is in your path. Then use the following command to open the file in the NetBeans editing area.
netbeans --open file
Even better, make an alias:
alias nb='netbeans --open '
Then you can simply type nb file. The command will start up the NetBeans IDE if necessary. If the IDE is already open, the command simply opens the file and pops it to the front of the editing area.
If you are using Windows, you can also do the following to open a file in the IDE.
- Right-click on a file in an explorer window.
- Choose Open With > Choose Program.
- Select NetBeans from the program list. If NetBeans is not on the program list, click Browse, navigate to and select netbeans-install-dir/bin/netbeans.exe, and click open.
- Click OK. The file opens in the IDE. Sometimes the IDE does not show the file's tab right away so it looks like the file has a different name. If you hover over another tab, the file's tab usually appears.
For more information, see wiki.netbeans.org/wiki/view/FaqCliOpen