Friday, February 20, 2009

Opening NetBeans projects and files from Linux File Browser

This post covers the topics as follows:
  • How to add Open with NetBeans option in the Ubuntu (Nautilus) context menu?
  • How to open Projects and files from Linux File Browser (in our case Ubuntu Nautilus)?
  • How to use Netbeans IDE as a generic file editor?
As described in the earlier post NetBeans IDE has a command line option --open which allows us to open any file and folder through command line in NetBeans IDE.  Let us check how easy it is to add a context menu option on Linux for this technique.

Adding Open with NetBeans context menu in Linux File Browser
We will open File Browser in Ubuntu which happens to be Nautilus application.  We will navigate to the user home and on the folder icon we will right click to see the context menu.  We will select the option "Open with Other Application..." option.

Open With dialog box will be shown with the "Use a custom command" portion collapsed.  We will click on this portion to get the expanded view of the dialog

The expanded view of the Open With dialog will allow us to type the custom command, which in our case will be 

/usr/local/netbeans-6.5/bin/netbeans --open

The folder will get open in NetBeans IDE when we will press the Open button now.  Not only this but now the option of Open with NetBeans will be added to the context menu for this user. We can check that by navigating to any folder which is a NetBeans project and right clicking it.  Now we can see the Open with "netbeans" option in the context menu.

This makes opening projects in NetBeans IDE a piece of cake.  Not only projects but any folder can be open like this in NetBeans IDE using this context menu.  If the folder is not a NetBeans Project it will get opened like a folder explorer panel which is very handy to work with files.  See how the opened project looks like when opened through this context menu.

Opening files using context menu in File Browser in Linux
Using the same technique we can also add a context menu for files.  Let us right click a file and select the "Open with other Application..." option from the context menu.

Again the Open With dialog will pop up. We will type the same custom command here also.

Now the context menu for files is ready to use.  Let us right click on any file and we get a Open With sub menu, which has many options including the Open with "netbeans" option also.  Now we can use this context menu option to open literally any file from the File Browser.

When a file is opened like this NetBeans IDE provides all the syntax highlighting features for the file type.  This makes NetBeans IDE a general purpose editor for any file.

I also tried to run a simple Java file opened like this in NetBeans IDE and it executed and displayed the output on the output window.

with regards
Tushar Joshi, Nagpur

Thursday, February 19, 2009

Open with NetBeans context menu in Windows

This post covers the following topics:
  • How to add Open with NetBeans to windows file and folder context menu
  • How to open any file in NetBeans without creating a project
  • How to use NetBeans IDE as a file and folder explorer
  • How to use the --open command line option for NetBeans IDE

--open command line option for NetBeans IDE
NetBeans IDE identified --open command line option and opens the file or folder given as an argument after this command line option.  This fact makes the NetBeans IDE useful to open any file and folder through command line.  In windows we can use this feature to introduce a context menu for files and folders in Explorer by tweaking the Windows Registry.

Adding Open with NetBeans option to windows context menu
In windows we can add two extries to the Windows Registry to add Open with NetBeans option to the Windows Explorer context menu.  These entries need absolute path of the NetBeans IDE executable so while trying this trick please check the NetBeans IDE executable path.

My NetBeans IDE 6.5 executable path is

C:\Program Files\NetBeans 6.5\bin\netbeans.exe

We can add the registry entries manually by opening the regedit.exe application from the Start > Run menu, or we can create a REG file to achieve this.  Creating the REG file is the easiest option.  We will create a file with name openwithnetbeans.reg and we will copy the following contents in that file. Double clicking this REG file will add these registry entries to the Windows registry as required.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Open with NetBeans\command]
@="\"C:\\Program Files\\NetBeans 6.5\\bin\\netbeans.exe\" --open \"%1\""

[HKEY_CLASSES_ROOT\Folder\shell\Open with NetBeans\command]
@="\"C:\\Program Files\\NetBeans 6.5\\bin\\netbeans.exe\" --open \"%1\""

Now when we open the Explorer and right click on a NetBeans project folder we get option as Open with NetBeans and clicking on this option will start the NetBeans IDE and will open this project in the IDE.

We can see the project open in the NetBeans IDE for us.

When NetBeans IDE is already open this command will open the project in the existing IDE.  

Opening any file in NetBeans IDE from Windows Explorer
Now when we right click on any file in the Windows Explorer we get the same option of Open with NetBeans and the file gets open in the existing NetBeans IDE or if it is not open a new one is started for us.

This makes NetBeans IDE a general purpose editor for me to edit any file in my computer.  

with regards
Tushar Joshi, Nagpur

Tuesday, February 17, 2009

Using Command Line Arguments in NetBeans IDE

This post covers the following points:
  • How to open the project properties dialog box for NetBeans IDE projects?
  • How to use command line arguments while running programs through NetBeans IDE?
NetBeans IDE provides a way to invoke our Java program having a main method with command line arguments.  Let us walk through this process.  We will create a new Java Application project and will add some code to the Main method which will print the provided command line arguments on the console.

Test Code we have written in the Main method:

* To change this template, choose Tools | Templates
* and open the template in the editor.
package com.tusharvjoshi.argsdemo;

* @author Tushar Joshi
public class Main {

* @param args the command line arguments
public static void main(String[] args) {
if (args.length == 0) {

System.out.println("No Command Line arguments");

} else {

System.out.println("You provided " + args.length
+ " arguments");

for (int i = 0; i < args.length; i++) {
System.out.println("args[" + i + "]: "
+ args[i]);

Opening the project properties dialog boxWe can either right click on the project name in the Projects panel and choose the properties option, or we can choose the Project Properties option from the File menu.

Saving the command line arguments

In the project Properties dialog box we will have to choose the Run node from the left Categories tree.  As soon as we select the Run node we can see the options for the run configuration.

In the Arguments text box we have to type our command line arguments.  We can see we have typed "one two three" as the options in the dialog box for testing.

Now when we Run the project the project will run as if these command line arguments are being typed in front of the java command.  We can see the output window to check how the arguments are printed by our test code.

with regards
Tushar Joshi, Nagpur

UPDATE: 21 Mar 2014:
There is a plugin available for NetBeans IDE 8.0 which allows interactive command line arguments facility to the IDE, more details are in this post

Monday, February 2, 2009

NetBeans Voice of Community Process (VOC)

NetBeans is growing day by day as a IDE as well as a platform for RCP.  There is considerable volume of community attached with the NetBeans development and looking forward for the new features getting inroduced and also to the issues they face with the NetBeans IDE.

Feedback from Community
Community has many ways to manifest their feedback in the current Web2.0 age.  They write blogs, they write twitter messages, they write forum posts, they file bugs and request for enhancements in the NetBeans IssuZilla.   They write mails in the mailing lists like nbusers nbdev and openide.  

One more effort to listen:
It is thought that increasing overall satisfaction with NetBeans will support Word of Mouth adoption of the IDE which will support further growth of NetBeans userbase. That's why we needed a coordinated process whose primary motivation is to fix issues not only show that we care.

What is VOC?
NetBeans Voice of Community process is started keeping this in mind and it is a team of 3 community members and one representative from Sun. Along with me the other two community members who are now called as VOC Captains are Annabel Melongo and Michel Graciano.  The Sun representative is Jiri Kovalsky.

How VOC will work?
Channels are identified to gather feedback like mailing list, netbeans chat, blogs, forums like DZone, TheServerSide.  So as soon as we find a issue or feedback which has BIG impact on NetBeans and where we know the reported of the issue and when the issue is reproducible we will register that issue as VOC issue and it will be given priority by the development team in the process of development of NetBeans.

How to send feedback directly to VOC?
Community members and NetBeans users can directly send their feedback to the VOC mailing list at No subscription to the mailing list is needed to send the feedback.

VOC Page

with regards
Tushar Joshi, Nagpur