My office uses Eclipse for the main development projects. This was a decision taken in the beginning of the product life cycle and must be maintained for the whole project as the sand boxes and developer documentation release documentation contains references to Eclipse.
When there is a need of decent GUI to be developed my team members face challenge playing with different layout managers and hand coded Java classes. The GUI building mechanism in Eclipse is available for commercial plugins like MyEclipse which we are not willing to use as company policy.
NetBeans IDE 6.1 Beta comes to rescue us from this situation. NetBeans IDE 6.1 Beta can import the Eclipse project as it is and even without shifting the source files. It only creates a configuration folder for the nbproject files and maintains the project in the Eclipse workspace. This provides a facility of working in same code base with Eclipse IDE as well as NetBeans IDE at the same time.
As an example let us see one simple PhoneBook application which I started as a project in Eclipse 3.3 Europa.
I used the Eclipse Project Importer module in NetBeans to import the project by specifying the workspace of the PhoneBook project. (Please refer to earlier post for importing eclipse projects). We can see below the project as seen in the NetBeans IDE.
In NetBeans I started the JFrame wizard by right clicking the package and choosing the
New > JFrame Form option...
NetBeans offered me to type the name of frame which i filled as PhoneBookFrame and clicked Finish to complete the wizard.
NetBeans created JFrame form class for me. NetBeans shows GUI classes with Design as well as source editors and we have facility to use the Matisse GUI designer available in NetBeans.
I designed a decent GUI on the JFrame very quickly by dragging the controls and assigning them appropriate properties in the properties window. NetBeans created appropriate code in the PhoneBookFrame.java class for me automatically.
Then I copied the code inside the main method of the JFrame auto-generated class to my main method in PhoneBookDemo.java main class and ran the project to see the application GUI.
The real magic starts now when I came back to my Eclipse editor. I refreshed the project and could see the newly created PhoneBookFrame.java class in the project file list. There is no error shown this proves that NetBeans does not use any custom package not available in Java distribution. Even if use the Matisse GUI designer the code emitted is using standard Java packages and classes.
So when I executed the code in Eclipse it also showed the same GUI. Wow! this is too good. Now I do not have any problem designing GUI even in my Eclipse projects.
I just have to import the project in NetBeans and design and generate the GUI classes through the goodness of NetBeans Matisse designer and then I can continue development even in the Eclipse editor for the rest of the project.
I think NetBeans has done a great job in providing the Eclipse Project Importer and especially the feature of working simultaneously keeping the workspace and the source code at the same place. This way I can assign the GUI design to one team member who will work on NetBeans only and handle all the GUI designing tasks and rest of the team can continue in routine tasks of calling the GUI classes.
This will also provide my team members exposure to NetBeans IDE even if they work on Eclipse as their main development IDE. Who knows for the next project we may opt for NetBeans IDE altogether.
with regards
Tushar Joshi, Nagpur
Tuesday, April 8, 2008
Eclipse Project using GUI designed from NetBeans IDE 6.1 Beta
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
