Monday, December 29, 2008

Opening multiple NetBeans IDE instances simultaneously

Main concepts in this post:
  • --userdir NetBeans command line switch
  • opening multiple instances of NetBeans IDE
  • Netbeans about dialog box

This post answers questions like:
  • How to open two NetBeans IDE simulteneously?
  • What is NetBeans user directory?
  • What is the --userdir NetBeans command line switch?
  • How to know the current user directory of NetBeans?
  • How to use same NetBeans installation to open two instances?

Many a times we need to look two projects at the same time in NetBeans IDE.  If both the projects are open in two seperate NetBeans IDEs that will be easier to look into one IDE instance having one project and code into the other instance of the IDE for the other project.


The NetBeans IDE maintains one user directory for one instance.  The trick is to make seperate user directories and make shortcuts of NetBeans IDE to start the instances in those seperate user directories.  Through these shortcuts we can pass the instruction to the IDE about what user directory to choose while running the instance.

Let us take an example.  We will create two directories

1. D:\nbuserdir1 

and

2. D:\nbuserdir2

Now we will create two shortcuts on the desktop which can be done by copying the NetBeans shortcut in the start menu and making two copies with dufferent names.  Now we will right click on the shortcuts and will choose the properties.  Then we will change the execution path and add the additional part to that command as




<netbeanscommand> --userdir D:\nbuserdir1 for the first shortcut 

and

<netbeanscommand> --userdir D:\nbuserdir2 for the second shortcut.


Now we are ready to execute the NetBeans IDE in two instances.  When we double click on those instances we will have two seperate IDEs running simulteneously.

To check which user directory is currently used by the running IDE we can open the Help > About diablog box.  This dialog box will also show us the user directory used by the running instance.
 


with regards
Tushar Joshi, Nagpur

20 comments:

  1. The bad thing is that we should also migrate all non-project specific settings like key shortcuts, templates etc.
    And I don't even want to mention working with more than 2 projects...
    Actually, I was really surprised to know this kind of behavior... Every other IDE supports multiple instances execution, because it's something really essential...

    ReplyDelete
  2. @Fantast The issue you mention can be solved by copying the existing user directory and rename it and giving that as value for --userdir. I agree that this should be supported by NetBeans by default like the workspaces in Eclipse.

    ReplyDelete
  3. i don't understand why we have to get inconvenienced like this. Every tool allows the developer to launch multiple instances. Having multiple instances has nothing to do with where your files are or your workspace if you will.
    Could someone from Netbeans take a look at some other IDEs like ecplise, VisualStudio, Qt, ... to see how they do this?

    ReplyDelete
  4. @dude, the workspace enhancement is filed as an RFE in NetBeans issue list. You can vote for it and join others to push that issue ahead in community preferences.

    with regards
    Tushar

    ReplyDelete
  5. Good tutorial but what about netbean on linux. I m using fedora and netbean 6.9, what should i do, my user directory in about dialog box is "/home/dev/.netbeans/6.9"

    ReplyDelete
  6. @Nehal,

    I see no issues using this concept even on Linux or Mac. We can start NetBeans IDE from command line by providing a userdir parameter.

    Create two separate userdir folders and pass them on the command line to start two separate NetBeans IDE instances.

    with regards
    Tushar

    ReplyDelete
  7. Great! In my case, I have any Magento and Zend projects and as you know, the files structure is too complex, so your trick is good for me. Thanks a lot.

    ReplyDelete
  8. Thanks for sharing your solution to concurrent instances of NetBeans IDE for simultaneous project work.

    My solution before having read this was to have all my projects as defined in the sidebar, and have my current tabset consist of files within a given project. To declutter, I maximize to one tabbar/tabset at a time and switch around that way as I hop projects.

    The problem has arisen that I am working on two significantly large requirements in the same "Project" now: Ongoing Production Maintenance and XYZ Big Feature Request. All my tabs look identical! Wish I could name tabsets/tabbars or color them to differentiate.

    ReplyDelete
  9. Thanks for the comment @bronius.

    1) The idea of colored tabs seems interesting. This idea deserves to be added as a RFE in the NetBeans issue tracker. Please add this as an enhancement.

    2) You can also think of using a Task Focused interface for NetBeans like Cubeon or NBTaskFocus which will allow you to work on Tasks and their specific context of opened files.

    with regards
    Tushar

    ReplyDelete
  10. Done with Netbeans 7.1.1 - thanks.

    ReplyDelete
  11. how do you separate the metadata in NetBeansProjects folder so each instances will only scan certain project directories. basically when i open instance1 i want it to only know about proj1 and and background scan for that proj only and only that proj will be listed....and when i open the 2nd instance it whould only know about proj2 and its files. thanks

    ReplyDelete
  12. Wonderful. works also with netbeans 7.4 .
    Am using Fedora 18 and this is what i did

    /bin/sh /usr/local/netbeans/bin/netbeans --userdir /home/netbeans2

    ReplyDelete
  13. Easy to follow, straight forward, nice done, thank you!

    ReplyDelete