Saturday, October 5, 2013

How do you start a new thread from plugin start() method upon plugin active.

We can call below particular snippet from any plugin start() method. 

final Bundle currentBundle = getBundle();
Job serviceJob = new Job("services starting...") {
protected IStatus run(IProgressMonitor monitor) {
while (currentBundle.getState() != Bundle.ACTIVE) {
try {
Thread.sleep(1000); //wait for some time and then re-check
} catch (InterruptedException e) {

startService();  //service implemenation goes here - this what you wanted to do after plugin is active

return Status.OK_STATUS;

Friday, October 4, 2013

Where does Java process ID's(pid) are stored ?

Got to 'Run' command,
Type  %temp%  and hit enter.

This will open up the 'Temp' folder in your local user App data.

Look for a folder hsperfdata_<systemLoginName>

example:  hsperfdata_KK1205

Complete path looks like below:

Inside of 'hsperfdata_KK1205' you can find currently running java process id's.

Thursday, October 3, 2013

Eclipse Mac OS - Context-sensitive help

 Please find the below link on context sensitive help from Eclipse for various platforms.  Please go through the “Context-sensitive help” section.

 As mentioned in the Eclipse documentation,  “ F1(Shift+F1  Help on the Mac). Alternatively, in dialogs you can achieve the same result by pressing the   help button in the dialog's button bar.”

To make it clear, Eclipse Mac is not providing the context sensitive help the way how windows (using F1) is providing.   You have to use’ help’ key in Mac keyboards or ‘command+shift+?’ in mac pro’s to point to the Help search.

 To use context-sensitive Help on Mac OS, set a keyboard shortcut to the Dynamic Help command. Eclipse ‘Dynamic Help’ option is available for Windows and as well as Mac systems.
This can also be used to get the context sensitive help documentation.

To specify a keyboard shortcut for the Dynamic Help command, do the following:
1.       Select Eclipse > Preferences.
2.       In the tree view, select General > Keys.
3.       Select the Dynamic Help command.
4.       Press the key binding combination that you want to set. For example, to enter Ctrl+Shift+1, press and hold the keys Ctrl and Shift and then press 1. A plus sign (+) between the keys indicates that you must press the keys in succession.

Now, you will be able to get ‘ context sensitive Dynamic help’ doc.  This provides the exact documentation whatever you are getting in windows through Dynamic help (This could be different from what you are getting for ‘F1’ help in windows but this would be same as what you are getting through dynamic help in windows).

Eclipse Mac OS - shortcut keys

Shortcut keys for Mac and Windows users @

Eclipse Mac OS- Scrollbar in navigation viewer

Bydefault, scrollbar option is not visible for navigation viewer in Eclipse for Mac OS. Unless you try to drag it, you will not realize that there is a scroll available for it.

To make it available explicitly, check “Always” option under Show Scroll Bars in System Preferences. If you enable that option you will get both horizontal and vertical scroll bars for navigation viewer.

IP address validation

Any IP address has to fall into [0-255].[0-255].[0-255].[0-255] format criteria.

We can achieve this by using following 2 ways.

Using split method of String: The method described above can also be written in a simple way as follows

public boolean validateIPAddress( String ipAddress ) {

String[] tokens = ipAddress.split("\\.");
if (tokens.length != 4) {
return false;
for (String str : tokens) {
int i = 0;
try {
  i = Integer.parseInt( s );
  } catch (NumberFormatException e) { //if any character data is entered.
   return false;
if ((i < 0) || (i > 255)) {
return false;
return true;

Using regular expression: The following method with return true is the IP Address is valid, else it returns false.

public boolean validateIPAddress( String ipAddress ){

final Pattern ipAdd= Pattern.compile("b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
+ "{3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)b");
return ipAdd.matcher(ipAddress).matches();

If it's is false, we can show error message as "IP Address must be in the in the format of:  [0-255].[0-255].[0-255].[0-255]"

Wednesday, October 2, 2013

Eclipse bundle states

Below diagram explains in which state your eclipse bundle is in.

To understand each state of these, please follow the below link