# Building MyRCP..

Recently, I posted a question on NetBeans Forums as I was interested in knowing how to get started with building NetBeans Platform. So, I will be sharing the steps I followed that made my work easy.

### Getting Started

Well, I have downloaded the source code for NetBeans Platform 6.X, as well as two JDK’s [1.5.0_22 – 64bit,  1.6.0_18 – 32bit] on Windows 7 – 64bit OS.  Assuming ANT_HOME, JAVA_HOME set properly and added to PATH.

It’s not necessary that you download the same JDK’s, however it’s necessary to have a copy of JDK 5 and 6. Because some versions of NetBeans code are built using JDK 5, while v6.8 can be built using JDK 6.

### Steps To Be Followed

1. Extracted the source code of NetBeans Platform 6.X under MyRCP\NbRcp_6X on my OS.
2. cd some\path\to\MyRCP\NbRcp_6X
3. cd nbbuild
4. ant -Dcluster.config=platform build-platform -Dnbjdk.home=”%JAVA_HOME%”
OR
ant -Dcluster.config=platform build-platform -Dpermit.jdk6.builds=true
5. Zip the netbeans directory created under MyRCP\NbRcp_6X\nbbuild directory and extract it wherever necessary/version-control the netbeans directory.

There you go, you have build your own RCP. Go, get started by adding the newly built platform in your NetBeans 6.X Platform Manager.

Last year, I had written a blog on Hyperlink Navigation Renaissance, here’s brief overview;

After lot of discussion on OpenIDE mailing lists, exploring Developer FAQ’s, exerting my wrist, flexing fingers and what not? Finally, hit the deck hard! Yeah, Hyperlink Navigation in NetBeans got smarter! Especially, for HTML documents.

That time, I had developed a plug in, which I have started to discuss about more these days. Yes, its Revamped Hyperlink Navigation and here are list of blogs discussing about it;

These blogs basically describe the history of this plug in, pointers to available resources at Kenai and how do I use SVN for managing the plug in source code from CLI, as well as from NetBeans IDE.

Now, I would like to tell you that there has been many changes since and I thought community would be interested to see the updates in the tutorial, I wrote last year. Have a look at this wiki for updates, rather than the entry at NetBeans Zone (If you want to, then see the comments for updates).

### Changes done..

I have got rid of overloaded setPosition methods, instead there would be one method from now onwards. While, some of the methods were renamed and some are no longer parameterized. This has reduced lot of redundant code and now, the code looks really neat. Making use of various editor features to cut-short long line of codes has helped.

Also, I removed the parameterized constructor, instead introduced a public method to pass necessary parameters from HyperlinkProvider implementation. This was done so as to possibly introduce an interface, which the module would depend on, while its implementation is available in another module. Yes, I am trying to make use of Lookup API to achieve same result.

Only issues I have, that currently one module can only depend on another user-defined module within a suite project. However, module I created is standalone one and its not possible to depend on another module, AFAIK. If you know of ways to do so, let me know or join this project to work towards achieving this.

### NetBeans 6.7 and Manage Platforms..

All of this was possible due to a feature I recently discovered in NetBeans 6.7 IDE, which was there in previous releases as well. However, I never really explored it. By the way, NetBeans 6.7 FCS is released. Check out the new, super cool homepage of NetBeans DOT org.

Stay tuned..

# SVN using CLI and NetBeans

Recent exploration in the world of FOSS has helped me adopt SVN more easily than ever before. In this post, I will share some of my learnings about working with SVN using CLI and NetBeans.

Basically, I am going to map every possible command that were used on Command Line Interface (CLI), during past 2 weeks to the functionalities provided by Subversion Support in the NetBeans IDE (6.0+).

#### Using 6.7 RC2 for demonstration,

After making project and their respective copies in the SVN repository of my plug in at Kenai. I forgot to update the /trunk after I had fixed a bug that was affecting plugin’s version v1.0, which was fixed for version v1.1. Actually, I had earlier made a tag by copying the sources from “/tags/release60_base/plugin-code-base” to “/tags/release60_fixes/plugin-code-base”.

I started fixing the code in the tagged repository before renaming/moving the repos to “/branches/release60_fixes/plugin-code-base”. Then, I realized that I had not merged the changes to the /trunk, which was required. So, we will see in the rest of this blog, how to do the merge using CLI and NetBeans IDE.

### Using Command Line Interface

Now, I need the working copy of the code kept at /trunk, so I have to do a checkout, first.

svn checkout URL

You can learn more about the checkout from the book of Version Control with Subversion. I have substituted URL with https://kenai.com/svn/nbrcp-kolektiv~incubator/nbplugins/branches/release60_fixes in the above, as well as the following command(s).

Now, having read the common use-cases of Merging Whole Branch to Another in the book, I decided to give it a try using CLI. So, I did the following;

svn log --stop-on-copy URL

Here’s what the book states;

The log subcommand will normally show every change ever made to the branch, including tracing back through the copy which created the branch. So normally, you’ll see history from the trunk as well. The --stop-on-copy will halt log output as soon as svn log detects that its target was copied or renamed.

Now, this presents the required textual information, and I found out that copy was made in revision r25 and last commit was made in revision r32. Now, we know where the changes took place since making the copy of trunk in r25. As per the book, I used the following command to do the merge;

svn merge -r 25:32 URL

Firstly, change the directory to the working copy and if we use svn merge, it assumes that current directory is the working copy. So, it will apply changes that happened between r25-r32 to the working copy. It may happen that there might be some conflicts, which you can resolve from command line. Now, use the following to see the status and detect any conflicts of the working copy after merging has been done;

svn status

The console output shows only modifications (denoted by M), addition (denoted by A)/deletion (denoted by D) or conflicts (denoted by C). If there are any conflicts, they are required to be resolved. So, please refer this guide on how to resolve the conflicts using CLI. Once they are resolved, you should commit the changes to the server (/trunk).

svn commit -m some_message

where some_message = “Merged changes r25:32 into the trunk..”

Hit Enter button to send the changes to the server. The book states,

Again, notice that the commit log message very specifically mentions the range of changes that was merged into the trunk. Always remember to do this, because it’s critical information you’ll need later on.

### Using NetBeans IDE

Now, I will show you how to do the same using NetBeans IDE to increase productivity, without worrying about typing issues that may occur using CLI. Also, changing directories, retrieving logs, doing manual merge, etc.

All of these may go easily wrong.. Although, its good to know how to work using CLI. Its much better to use IDE’s for the same purpose. Thus, I have written this blog that may help you switch to NetBeans IDE for the same.

#### Checkout..

Firstly, goto Team | Subversion menu and select Checkout… This will open a wizard where you will enter the URL, username and password. Now, refer this blog on how to checkout the code and configure it, as per the requirements. Once its done, project will be opened and displayed under Projects window.

#### Merge Changes..

Right-click the project node and select Subversion from the context menu. Then, select Merge Changes.. from the menu as displayed here;

Soon, following window opens that lets you configure the way you want the merge to happen and that too, in one step! Have  a look;

You can see various options in the form of drop-down list and browse, search buttons. I willl brief you about the same as we move ahead. Drop-down list have three options to choose from;

Type I – One Repository Folder Since its Origin

Type II – One Repository Folder

Type III – Two Repository Folders

So, I selected Type II because I want to merge changes from single repository folder (/branches/release60_fixes) which is other than the working copy, synchronized with (/trunk). This preview is shown within the same window and can be viewed by scrolling down the same window.

Browse.. will let you choose the repository folder to merge from. We will choose /branches/release60_fixes/ahrefhyperlink.revamped (This folder might change in future, you may expand /branches as shown in the figure to observe changes taken place) for merge. Have a look;

At the beginning of this entry, I mentioned that one can find out that changes between which versions have to be merged in the working copy. To do that, one has to make use of svn log. In this case, one would just click the Search.. button and following window pop-up!

Clicking List will list all the changes that have occurred since the date entered in the shown field. As you can see tag was made in r25 and last code update took place in r32. So, we will first choose the revision #25 for Starting Revision and #32 as Ending Revision, one-by-one. See the following figure;

This works same as the  svn merge command used earlier. Click Merge button to commence the merge operation. Once the merging is finished, one can see whether there are any conflicts or not.

Conflicts may occur, when the HEAD revision of the /trunk repository is not in sync with the other repository, when sources were first copied from /trunk. See the following figure, I got two file conflicts;

For resolving conflicts, you may refer this guide written by Sun Technical Writers. Once conflicts are resolved, you must now commit the sources with this message as recommended earlier, “Merged changes r25:32 into the trunk”. That’s all for the day. Hope this helps you get started effectively.

Reference Guide
http://www.netbeans.org/kb/60/ide/subversion.html#merging

# NetBeans Plugins at Kenai | #2

This post will focus on work flow of my plug in Revamped Hyperlink Navigation (RHN). Without much ado, lets get started..

#### Getting Started

Firstly, you need to access the existing sources available for plug in, published in Update Center for NetBeans 6.0 and then, I will use NetBeans 6.5 as the development software for demonstration. So, run NetBeans IDE (bundled with either Java SE, Java or All technologies).

#### Checkout Sources..

Open Versioning | SVN menu and select Checkout… from sub-menu. Checkout Wizard opens.. Now, enter Repository URL as https://kenai.com/svn/nbrcp-kolektiv~incubator/nbplugins/tags/release60_versions and click “Next >.

You might be prompted by the NetBeans to accept certificate, click on Accept Temporarily and continue.. Now, click on the Browse button to select the Repository Folder needed to be checkout. Select /rhn_v11/ahrefhyperlink.revamped and specify your Local Folder. Also, select the checkbox with label as Scan for NetBeans Projects after checkout and click Finish. NetBeans will prompt you to open project AhrefHyperlink (Revamped). Click Open Project and NetBeans will open the project for you. Now, right-click the project node and select Properties.

Reference Guide
http://www.netbeans.org/kb/60/ide/subversion.html#checking

#### Manage Platforms…

Now, goto Libraries and you will notice that NetBeans Platform selected for project is the default build provided by the NetBeans 6.5 IDE, and similarly for Java Platform. So, you need to configure the project to be built against NetBeans 6.0. Therefore, refer this tips and Tricks to learn how to “Manage Platforms…“. Also, choose JDK 1.5 for Java Platform (JDK 1.6 should also work fine).

#### See Module in Action..

Once you are done with it, click OK to save project properties. Now, Clean and Build the project and Run to see this module in action. If success, the NetBeans 6.0 splash screen pops up and soon, NetBeans 6.0 instance is running with the plug in, installed. Try out the cases specified in the tutorial and then, try out some new one’s from your side. Observe where it works and where it doesn’t.

If you find any issues/bugs, kindly file it using JIRA Issue Tracker used for this project and select component nbm-hyperlink. Soon, I will write wikis so as to help you understand how to file issues for this project. Fixed sources are stored under /nbplugins/branches as /release60_fixes/ahrefhyperlink.revamped (Links updated).

Unstable code is placed under /nbplugins/trunk and you may see what new developments take place there.

Stay tuned for more!

# Configure NetBeans using Batch Files..

Well, we all know that although editing “{netbeans.home}\etc”\netbeans.conf is not a big deal for any developer, it certainly takes a toll, if you’re using daily builds. That means, everytime you download new build of NetBeans you will modify the configuration file to tune JVM switches as per your operating system.

Last year, when I participated in NetCAT 6.5, I had this problem, i.e. I did the same configurations again and again, every time I downloaded latest build. Recently, when I downloaded 6.7 RC1 to make use of Kenai and Hudson integration, few days later I got the notification of 6.7 RC2 and related CA survey. Today, I downloaded that too, but it makes me feel sick to do those configurations all over again.

#### CLI (Command Line Interface)

There are people who write many scripts to ease their work by automating some tasks. As I was not good at using CLI, as I am right now. So, I thought of giving it a try and I looked into the internet to learn some batch programming. After exploring for some amount of time, I have written a batch program to help me with the task and here’s what I got;

for /d %%X in (%1\NetBeans*) do edit "%%X\etc\netbeans.conf"

#### Explanation

This batch program has got only the for-statement and this is where I look for NetBeans installation directories stored under the directory provided as a runtime argument denoted by %1 For instance, I have installed 6.7 RC1 and RC2 under C:\Program Files. So, I will make use of this batch program on CLI like this;

nbconfig "C:\Program Files"

Now, the batch program loops through this directory passed as a runtime argument and will look for the right installation directory by making use of NetBeans* as matching criteria. Once it finds the directories, it will loop each one of them, one-by-one and open the configuration file for editing.