Compiling and debugging an example plugin for gvSIG 2.1.0 from an IDE (NetBeans)

English translation of the article by Joaquin del Cerro.

Hi everyone,

I´m back to explain to you, how download the sources of one of the gvSIG project´s example and how compile it and debug it.

In this article, I will use as IDE Netbeans 8, which is the IDE that normally I use for developing with gvSIG long time ago. In the future, I will install an Eclipse and in another post I will tell you how to work with it. Anyway, if you are a developer used to Eclipse, it would not be difficult to take the explained ideas.

Keep in mind that this post doesn´t want to be a NetBeans tutorial, just to explain the steps to follow for being able to download and compile gvSIG plugin with it.

Once you have already followed the steps described in the post  “Como descargar y compilar gvSIG 2.1.0 en Linux y Windows“ and we have all the basic tools installed and set up, we can carry on.

To follow this post, we need internet access. In general, for compiling gvSIG we need internet access. And also:

  • An Installable of gvSIG, in my case “gvSIG-desktop-2.1.0-2262-testing-win-x86-standard-withjre.exe”
  • An Installable of NetBeans

First of all, we install IDE, NetBeans.

I´ve downloaded it from the NetBeans official website, in downloads:

https://netbeans.org/downloads/

We will find a few distributions availables for downloading:

  • Java SE
  • Java EE
  • C/C++
  • HTML5 & PHP
  • All

With the distribution “Java SE” will be enough for compiling the majority of gvSIG projects (excluding the ones requiring natives, because they are out of this post´s scope)

Simply we will download it and proceed to install it.

Through the initial set up, it will ask us for two things, where are we going to install it and where is the JDK to use. In this case, we will choose the JDK which we have already installed like it was explained in “Como descargar y compilar gvSIG 2.1.0 en Linux y Windows“.

Once we have installed NetBeans, we will install gvSIG. It will be a standard setup but we will not install it in “Program Files”;, I advise you to install it inside c:/devel, folder, where we have already downloaded the gvSIG sources. I have installed in :

c:/devel/gvsig/2.1.0-2262

The reason of installing it out of “Program Files” is because in my Windows installation, the user doesn´t have administrator privileges and if I do it in there, I will have problems later when I try to deploy the plugin binaries over that installation. Writing on c:/devel folder (created by me), I will not have any privilege problems at all.

Once we have these two things installed, we change the pathfile on “.gvsig-devel.properties” for pointing to the installation of gvSIG which we have just done in “c:/devel”.

Well, one more thing to do. The actual distribution for Windows of gvSIG-desktop doesn´t include a launcher in gvSIG.sh of gvSIG. The launcher is only included in Linux distribution( in future distributions we will include it as well for Windows). Well, for the moment is not present, so we have two options, if we have alredy compiled “org.gvsig.desktop”, we can take it from “org.gvsig.desktop/target/product” folder or if we don´t have it on hand, we can download it from:

http://devel.gvsig.org/svn/gvsig-desktop/trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/resources-application/gvSIG.sh

We will leave it in the folder where we have installed gvSIG, along with the “gvsig-desktop.exe”.

Once we have these three things, we will boot NetBeans, then, downwnload the project “org.gvsig.landregistryviewer” and we will compile it. We will download it from the url:

http://devel.gvsig.org/svn/gvsig-plugintemplates/org.gvsig.landregistryviewer/trunk/org.gvsig.landregistryviewer/

To do it, we will go to menu:

Team->Subversion->Checkout…

netbeans-checkout1 It will show us the following screen:

netbeans-checkout2

Then, we will write in the field “Repository url” the value of the url (previously indicated) in where is the example project “org.gvsig.landregistryviewer”. We click on “Next”. It will show us the next page of the assistant, in which we should introduce the folder where we want to download the project. In our case, we will introduce “c:/devel”, and click on “Finish”.

netbeans-checkout3

When the project´s download finish, it will tell us about the maven projects presents in the donloaded project and it will ask us if we want to open any of them. The screen dialogue will be something like:

netbeans-checkout4 We click on “Open project…” to indicate which of the projects we want to open and it will show us:

netbeans-checkout5 We will select the project “org.gvsig.landregistryviewer” and click on “Open”.

When we try to load the project for the first time, probably some error will appear due to the fact that some dependencies are not downloaded, showing us a message like:

netbeans-checkout6 We only clik on “Close”.

Now, we will compile the downloaded project. To do that, we select it in the “proyectos” view and click on “Build project” of the toolbar.

netbeans-checkout7 The bottom console will be showing the compiling messages and once the process finishes, we will have our plugin compiled and deployed over the gvSIG installation.

netbeans-checkout8

So far, we have seen how to prepare our work environment, download and compile the plugin. If we want to see our plugin in action, simply we will boot Console2, go to gvSIG installation folder, c:/devel/gvsig/2.1.0-2262, and run gvSIG.sh.

$ cd c:/devel/gvsig/2.1.0-2262
$ ./gvSIG.sh

Let´s see how to debug our plugin.

We will open the subproject “org.gvsig.landregistryviewer.app.mainplugin”.

netbeans-abrir-proyecto1 It could happen that the plugin doesn´t realise that there are all the dependencies needed, already downloades when the project has been compiled.If this happens, iw will show us:

netbeans-abrir-proyecto2 In this case, we click on “Resolve Problems…” for updating the dependencies. It will show us:

netbeans-abrir-proyecto3 We click on “Resolve…” and wait until the project update. When the update is finished, the atención signal should dissapear and we will close the dialog clicking on “Close”.

Now, we will load the class LandRegistryViewerExtension and put a breaking point at method´s start CreateViewWindow. To do this, we click twice in the line´s number.

netbeans-debug1 Once done the breaking point, we will go to Console2 and we will go to boot gvSIG, but passing before the parameters “–debug –pause”.

netbeans-debug4 This boots the JVM activating the debug for being able to connect with it.

netbeans-debug5 It is possible that depending of the firewall setting, it will show us a message or even that doesn´t work. We need to make sure that we allow the app java.exe to access to 8765 port.

Then, we will back to NetBeans, and connect to gvSIG in debug mode.

netbeans-debug2 It will ask us for connection data…..

netbeans-debug3 When click on “OK”, it will carry on with the running of gvSIG in debug. As we have put a breaking point, it will stop on it and we will be able to debug our plugin.

netbeans-debug7 If we need to see the code of gvSIG, we click on Ctrl-O and type the class name which we want to locate.For instance, if wew want to put a breaking point in the proect creation, we will type Ctrl-O y “DefaultProject”

netbeans-debug8 And click on “OK”.

netbeans-debug9 If it doesn´t show us the source code (automatically downloaded, well, depending of our NetBeans setting), we can click on “Attach Sources…” and then “Download”.

netbeans-debug10 Once all the sources needed have been downloaded, we close the window clicking on “OK”. It will show us the code for the class “DefaultProject” and we can put a breaking point in its builder.

netbeans-debug11 Well, that´s it for today…..

All I have talked about is related to Windows 7. For Linux developers, it´s quite easy to follow and you just need to change the path c:/devel for the one that you use to leave the sources.

For Eclipse developers, the steps to follow are similars, the most complicated issue could be the support setting of maven which has already NetBeans.

It´s a post quite long (a lot of screenshots), but I think that they could be helpful to follow up the article.

I hope it was useful,
Greetings to all and thank you!

This entry was posted in development, english, gvSIG Desktop, gvSIG development. Bookmark the permalink.

One Response to Compiling and debugging an example plugin for gvSIG 2.1.0 from an IDE (NetBeans)

  1. Pingback: Compiling and debugging an example plugin for gvSIG 2.1.0 from an IDE (NetBeans) | Geo-How-To News

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s