X

Geertjan's Blog

  • September 9, 2005

Integrate Eclipse in NetBeans

Geertjan Wielenga
Product Manager
They're both so cool, why not just give up trying to decide which is better? Thanks to Ant integration in NetBeans, everything is integratable -- including Eclipse. The way I see it, Eclipse is a nice handy tool to add to your toolbox. Not for when you want to do J2EE/SOA stuff (because you've got to go looking around for their plug-ins, during which time, in NetBeans, you could've consumed two dozen web services), but when you want to code in some language other than Java, for example. Also, it's interesting to see how different products approach the same problem -- refactoring, for example. So, anyway, this is how you do it (it's actually been possible since NetBeans IDE 4.0, when NetBeans IDE became one massive anthill, warmly welcoming ants from all over the world and integrating them, giving them a special place in the IDE, and ensuring that they played nicely with each other):

  1. Create a standard application (any standard application) in NetBeans IDE. You get an Ant build file (build.xml) for free. Or, if you don't want to create an application in NetBeans IDE, just create an Ant build file somewhere in your filesystem. Then add the Ant build file to the NetBeans IDE Favorites window (Ctrl-3).

  2. Now that you have an Ant build file in NetBeans, add a target that starts Eclipse:
    <target name="Start-App-Eclipse">
    <exec executable="E:\\eclipse\\eclipse\\eclipse.exe"/>
    </target>

    Of course, you need to replace E:\\eclipse\\eclipse\\eclipse.exe with whatever the path to the Eclipse executable is in your environment.

  3. If it isn't open already, open the Navigator (Ctrl-7), click your Ant build file, and you'll see its targets listed as nodes in the Navigator. Now right-click the Start-App-Eclipse node and choose Create Shortcut...

    And now this is the first next thing you see:

    Cool, right? So now I can add a menu item, toolbar button, or keyboard shortcut that will invoke my target. (Or I can choose to create all three of these shortcuts.) So let's say I choose 'Add a Menu Item'. The next step in this wizard lets you specify where exactly your new menu item will be and what it's label will consist of. So then you set those things and... it's as easy as that, you now have Eclipse integrated in NetBeans:

    Now, whenever you choose that menu item, the Start-App-Eclipse target is called. And what does that target do? It invokes the Eclipse executable. So then Eclipse starts up and you do whatever it is that you need to do in Eclipse and then you switch back to NetBeans. So, maybe this "integration" does nothing more than start up Eclipse -- but, once it's started up, I'm sure there's got to be some creative ways of working with the same file in Eclipse as you were working on in NetBeans (probably definitely not projects, though, because those are IDE-specific). I'd be interested to see if anyone manages to be more productive thanks to this Eclipse integration than they were before...

Join the discussion

Comments ( 6 )
  • Lucian Pintilie Friday, September 9, 2005
    Without intending to be rude, I think this kind of posting is rather harmful than helpful to NetBeans. Both IDEs can invoke an Ant target. Maybe Eclipse cannot promote such a target to a menu entry in the IDE, but this is irrelevant. Just picking on Eclipse does not necessarily help NetBeans.
    Besides, this is not even "integrating a tool" into the IDE. Doing what you say here does not allow NetBeans to use immediately whatever Eclipse produces. You cannot further control Eclipse from within Netbeans, at least not in an easy way.
    I think the focus here should more on explaining hidden features of NetBeans or features harder to grasp - like deployment issues, CVS issues, miscellaneous tasks involved in the life cycle of a project. That would allow faster adoption of NetBeans and promote its really useful features. Don't get me wrong, I like NetBeans, but I would like to see a more serious tone in published material promoting it.
  • guest Friday, September 9, 2005
    The last hurdle for me to switch is full refactoring capabilities. Once netbeans has this I am gone - eclipse is a dog. I have been waiting for a long time for these - but netbeans seems to have more interest in new features than refactoring. This is the reason I used eclipse in the first place...
    What is the timeline to get all the refactorings from eclipse into netbeans? How high up the priority list are these?
    I know they aren't "Sexy" but productivity is = to refactoring ability in my opinion.
  • Geertjan Sunday, September 11, 2005
    Hi Lucian -- thanks for your comment. As stated in the blog entry to which you refer, the integration "does nothing more than start up Eclipse". It's not much, but it's a start. I'm sure there are other ways to combine Eclipse and NetBeans. Secondly, I'm not picking on Eclipse at all -- I have written many blog entries about integrating various non-NetBeans software with NetBeans. And in this particular blog entry I only pointed out that you can treat Eclipse in the same way as, for example, JBoss, or DBVisualizer, or any of the other cool tools I've blogged about. And I was being serious in this blog entry -- in fact, I use this Ant shotcut to Eclipse all the time. I find it useful. And that's been the only criterium I have used in writing this blog, from the very beginning: I've always assumed that if something is useful to me, there's got to be at least one other person who's going to find whatever it is just as useful. So, each blog entry I write is written for myself (as a reminder of what I've learnt) and just one other person, but if more than that one person find it interesting, then that's a bonus. I'm sorry that you didn't find this particular blog entry interesting, but I'm sure there are others out there who do. (In fact, I wrote this particular blog entry in response to a question that someone had on nbusers-AT-netbeans-DOT-org.) And, maybe there's someone out there who, now that they know how to start up Eclipse from NetBeans, will go a step further and show some other cool way to leverage the work put into NetBeans together with the work put into Eclipe?
  • Geertjan Sunday, September 11, 2005
    Hi 222.153.153.104,
    To give you an idea of how serious NetBeans is about refactoring, here are two screenshots. The first shows you the Refactoring menu in 4.1 and the second shows you the Refactoring menu that you will see in the upcoming 5.0 release:

    <img src="http://blogs.sun.com/roller/resources/geertjan/refactor1.jpg">

    <img src="http://blogs.sun.com/roller/resources/geertjan/refactor2.jpg">

    And I'm very sure that every release after 5.0 will include more and more refactoring options. Really, refactoring is one of the area where NetBeans has been investing a lot of time.

  • Jens Friday, April 28, 2006
    MyEclipse Has incorporated Matisse. From The Server Side...
    Matisse4MyEclipse is the first Swing UI designer to integrate the best features from the Eclipse platform and Sun's Netbeans project to enable the easy creation of Java rich client applications within the MyEclipse environment. Maintaining development transparency, Matisse4MyEclipse offers full control and round trip development between RAD visual design tools and underlying Java Source code.
    http://www.myeclipseide.com
  • Geertjan Friday, April 28, 2006
    Yes, Jens, I know that. There's been a lot of discussion about this, as you probably know (since you from Genuitec).
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.