Saturday, March 22, 2008

Importing Eclipse project in Netbeans IDE 6.1 Beta

Today I will check the Eclipse Importer feature of the Netbeans IDE 6.1 Beta. I have a simple project written in Eclipse. I will now import that project in Netbeans and will run that project. As I have downloaded the very base Java SE pack of the Netbeans IDE 6.1 Beta I must ensure that the Eclipse Importer module is available with me.

The Tools menu has Plug-ins options in this version of Netbeans. So I chose to click on it.


I can see the plugins dialog box with many tabs. The Available Plugins tab shows all the available plugins on the Netbeans site. The installed tab shows all the installed plugins. There is a long list of plugins in the available plugins tab. Now how to locate the Eclipse importer module quickly. Here comes the Search filter feature handy.


I just typed the name Eclipse in the search filter text box on the right top of the dialog box and there was the Eclipse Project Importer plugin with its information available.


As soon as I selected the check box I could see that this plugin is 69kb in size and there was an Install button to install this plugin in my Netbeans.


I clicked the install button.


Netbeans started the plugin installation wizard. It confirmed from me whether this is what I really wanted :)


Netbeans showed me the license with which the plugin was available and obviously if I want this plugin I must accept the license agreement. I did that.


This was the Eclipse Project Importer plug-in was installed and I was notified of this fact with a dialog box.


I can now see the Eclipse Project Importer plug-in in my installed plug-ins tab in the Plug-ins dialog box. To quickly check this I again used the search filter text box situated at the right top corner of the plug-ins dialog box.

Now starts the real show. I have to import my project which I have written in Eclipse into Netbeans. The installation of the plug-in is just a one time activity and was needed just because I had downloaded the basic Java SE pack only. This plug-in may be bundled with the other bigger packs.

I can see there is a new menu available in the File menu drop down. Import Project option has a menu entry named Eclipse Project.

I clicked the Eclipse Project entry from the File > Import projects menu. It showed me a dialog box for the location of the eclipse project. There were options to select either the workspace or the project source folder only. Selecting the workspace is a simple idea so all the dependencies of the projects which are saved in the Eclipse workspace are also imported by Netbeans.


Here I pointed the workspace where I have created the simple Java project.


Netbeans showed me the projects available in the selected workspace. There was PersonExample my project. I checked that project and clicked the finish button.


Netbeans took some time to analyze the files and then opened a project for me in the left projects panel. I can now browse all the project files in Netbeans and also can compile them.


When I tried to run the project Netbeans asked me about the main class in the project. As this is an imported project Netbeans was not already knowing my main class and my project may have many classes with main method. Netbeans offered me a dialog box listing all the classes with main method and a choice for me to select the main class. I did that.


The output was as expected. This was just a Hello World program.


The most important fact was learned when I saw the folder where Netbeans created the importer project files for itself. What I can see is the configuration files only there was no actual code in this path. This highlights that Netbeans only creates a reference to the actual sources in Eclipse workspace. This means I can now work in Eclipse and Netbeans at the same time and keep the files at same place. This is great.



Just for curiosity I opened the project.properties file and saw the src entry pointing towards my Eclipse workspace. This made it clear that Netbeans Eclipse Project Importer module only creates reference to the actual eclipse projects and keeps the files where they are. This make working with Eclipse project and Netbeans on that project simultaneously possible.

with regards
Tushar

10 comments:

  1. The article is helpful, the only issue is that while I am using NetBeans 6.1, it seems that Eclipse Importer does not show up under Tools->Plugins wizard. Is there any chance to download the nbm file manually? I have also checked the Plugin Portal but no luck.

    ReplyDelete
  2. @nasos,

    Please follow the article screen by screen. It also works with the NetBeans IDE 6.1 release version. Please feel free to ask any question in the nbusers@netbeans.org mailing list or even here on this blog post

    with regards
    Tushar

    ReplyDelete
  3. Thanks for the tip, but do you know where the memory of the imports are? I'm trying to import projects to netbeans that I have imported before and then removed, but when I try to import them again netbeans skips them because they have already been imported.

    ReplyDelete
  4. Thanks!

    Once an Eclipse project is imported NetBeans creates "nbproject" folder for that project. You do not have to re-import it. Just say Open Project and point the earlier imported project in NetBeans and NetBeans will open that project this time as a normal NetBeans project. Hope this helps and now you also have a wonderful tutorial at NetBeans site at http://www.netbeans.org/kb/docs/java/import-eclipse.html

    with regards
    Tushar

    ReplyDelete
  5. Thanks for the tips. I never thought I would be able to import Eclipse project into Netbeans until I came across this article.

    ReplyDelete
  6. thanks.
    you explained it very well :)

    ReplyDelete
  7. i had some question which did not get it's answer in any forums like nbusers and so on.
    Project A has some jar files. project B depend on A. (library -> add project).
    but project A jar files (Classes) are not visible in B and i should add them separately.
    in big project it will be tedious. is there any way like eclipse and idea to export jar files with project
    (in my example project A).

    when importing eclipse projects into netbeans mentioned problems is encountered.

    please answer

    ReplyDelete
  8. Can we get the gui view of the imported eclipse project in netbeams for further editing

    ReplyDelete