Friday, December 12, 2014

Editing PATH and JAVA_HOME variables in Mac OS X

Step 1: Open up a Terminal window (this is in your Applications/Utilites folder by default)

Step 2: Enter the follow commands:

touch ~/.bash_profile; open ~/.bash_profile

This will open the .bash_profile file in Text Edit (the default text editor included on your system). The file allows you to customize the environment your user runs in.

Step 3: Add the following line to the end of the file adding whatever additional directory you want in your path:


export JAVA_HOME=/Applications/Kony_Studio/Kony/Java/jdk1.7.0_67.jdk/Contents/Home


Thursday, November 27, 2014

Eclispe Mac - Changing text file encoding

By default, mac eclipse is configured with US-ASCII text encoding, but this does not work out if your file is having some special characters.

When you try to save a file which is having some special characters, you will face the below problem.

By changing default text encoding from US-ASCII to UTF-8 will resolve the problem.

This can be changed from the eclipse preferences-> General -> Workspace.

Changing the Eclipse Java thread time out value

Did you ever face below kind of issue while starting your eclipse product ? 

!ENTRY org.eclipse.osgi 2 0 2014-11-28 11:17:57.835
!MESSAGE While loading class "com.kk.tool.model.KContainer", thread "Thread[main,6,main]" timed out waiting (5015ms) for thread "Thread[Thread-3,5,main]" to finish starting bundle "com.kk.tool_6.0.190.DEV_v201411271801 [664]". To avoid deadlock, thread "Thread[main,6,main]" is proceeding but "com.kk.tool.model.KContainer" may not be fully initialized.
org.osgi.framework.BundleException: State change in progress for bundle "reference:file:dropins/com.kk.tool_6.0.190.DEV_v201411271801.jar" by thread "Thread-3

There are two majors reasons for this.
1. Real dead lock would have occurred
2. Your product might have lot of bundles and each one of them might have dependencies on other plugins startup. Because of this, eclipse startup will be delayed.

If it is (1), we need to identify the root cause for a dead lock and fix it.

In general, OSGI controlling java threads time out by 5000 ms by default. We can control this time out by osgi parameter which need to be configured in the config.ini file.


You can find config.ini file in the configuration folder of eclipse directory.

Caution: Don't jump strait to the timeout solution with out really looking at the dead lock possibility, 99% of time problem might be there with our code only!!!!


Locking mac pro system - Lock Screen

I am new to MacBook's for my reference..

>Applications > Utilities -> Key Chain Access -> Preferences -> General Tab -> Check 'Show status in Menu bar'

After this you will find lock menu bar on your screen and you can see "Lock Screen" option

Wednesday, November 26, 2014

Web UML tool

This works for basic needs.

Common Eclipse development problems and fixes

StackLayout to switch between Composites

For example, If your dialog is having 2 radio buttons and based on the radio button selection you wanted to change the composite area. So rather than disposing the composite every time and recreating based on the selection of a radio button, we can manage this through stacklayout.

As per eclipse doc,This Layout stacks all the controls one on top of the other and resizes all controls to have the same size and location. The control specified in topControl is visible and all other controls are not visible. Users must set the topControl value to flip between the visible items and then call layout() on the composite which has the StackLayout.

public static void main(String[] args) {
                Display display = new Display();
                Shell shell = new Shell(display);
                shell.setLayout(new GridLayout());
                final Composite parent = new Composite(shell, SWT.NONE);
                parent.setLayoutData(new GridData(GridData.FILL_BOTH));
                final StackLayout layout = new StackLayout();
                final Button[] bArray = new Button[10];
                for (int i = 0; i < 10; i++) {
                        bArray[i] = new Button(parent, SWT.PUSH);
                        bArray[i].setText("Button "+i);
                layout.topControl = bArray[0];
                Button b = new Button(shell, SWT.PUSH);
                b.setText("Show Next Button");
                final int[] index = new int[1];
                b.addListener(SWT.Selection, new Listener(){
                        public void handleEvent(Event e) {
                                index[0] = (index[0] + 1) % 10;
                                layout.topControl = bArray[index[0]];
                while (shell != null && !shell.isDisposed()) {
                        if (!display.readAndDispatch())

This is something new learning for me!!

Wednesday, November 12, 2014

Eclipse: Adding a new console and writing messages to it

MessageConsole console = new MessageConsole("Node Console", null);
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{ console });
MessageConsoleStream stream = console.newMessageStream();
stream.println("Hello, world!");

This is how it looks..

Tuesday, November 11, 2014

Remove all .svn folders recursively

For my reference...

To remove all .svn folders from your project, we can run the following command from the root of the folder.

FOR /F "tokens=*" %G IN ('DIR /B /AD /S *.svn*') DO RMDIR /S /Q "%G"


Wednesday, October 29, 2014

Linking external project to eclipse workspace without really moving the project content

If you wanted to access the external eclipse project resources without really adding them into eclipse workspace, below piece code will help to do that.

 privagte void linkProject(String projectPath) throws CoreException {

IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription( new Path(projectPath + File.separator +".project"));

IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName()); 
project.create(description, IProject.FORCE, null);
 if (!project.isOpen()) {;


Saturday, October 18, 2014

Closing eclipse empty editor area

I have a use case, where I need to the close the eclipse empty editor area, so that editor area can be used by something else.

This can be achieved by implementing IPartListerner2 interface which is provided org.eclipse.ui.*

import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.editors.text.TextEditor;

public class AbstractMyEditor extends TextEditor implements IPartListener2 {

public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
public void partActivated(IWorkbenchPartReference partRef) {

public void partBroughtToTop(IWorkbenchPartReference partRef) {

public void partClosed(IWorkbenchPartReference partRef) {
IWorkbenchPage page = partRef.getPage();
if (page.isEditorAreaVisible()) {
IEditorReference[] editores = page.getEditorReferences();
if (editores.length <= 0) {

public void partDeactivated(IWorkbenchPartReference partRef) {

public void partOpened(IWorkbenchPartReference partRef) {

public void partHidden(IWorkbenchPartReference partRef) {

public void partVisible(IWorkbenchPartReference partRef) {

public void partInputChanged(IWorkbenchPartReference partRef) { }

Tuesday, October 14, 2014

Eclipse view id's

For my reference.

Eclipse view id's for progress view and error log view.


org.eclipse.ui.views.ResourceNavigator  => IPageLayout.ID_RES_NAV
org.eclipse.ui.navigator.ProjectExplorer  => IPageLayout.ID_PROJECT_EXPLORER

Monday, October 13, 2014

-vm in eclipse.ini is not considered during the eclipse launch in mac os x

I was facing this issue, I have multiple Java versions installed in my Mac system and I wanted to change my eclipse default Java version.

I have configured -vm parameter in eclipse.ini file in mac os x, but some how this parameter didn't take effect.

To resolve this issue, I have followed the below link.

What worked for me is, configuring libjvm.dylib path in the eclipse.ini file and info.plist file.



Add above entry in the last.

info.plist file can be found in below location:

How do I know with which version of Java eclipse got launched ?

Eclipse would have launched with some JRE support, to understand and know which version of java is used and from where it picked up. Follow these steps.

Go to Help->About Eclipse -> Installation Details -> Configuration

Look for below parameters:
java.home=C:\Program Files\Java\jre7
eclipse.vm=C:\Program Files\Java\jre7\bin\javaw.exe

Where can I find configured default Java/JRE in my Mac OS X system

Go to below location to find the installed JDK versions in your mac machine.


eclipse.ini -vm option

-vm argument is useful for passing virtual machine to the eclipse.ini. Mostly this will be used where your system configured Java is different and you wanted to pass different version of java version to the eclipse.

Please follow below link from eclipse

Example: In windows

Example: In Mac OS X

This argument should always before the -vmargs arguments and -vm and parameter value should specified in different lines.

In Mac OS X, some times this is not working. Even though we have specified in the eclipse.ini file, eclipse launcher is always taking the different jvm.

To resolve this issue, please follow the proposed solution in the below link

Copying files from Windows to Mac OS

For my reference

Download this software in Windows, this will allow to get the access to Mac os and you can easily transfer files from windows to mac using this.

Wednesday, October 8, 2014

Maximum heap size allocated on 32 bit JVM's

The maximum theoretical heap limit for the 32-bit JVM is 4G. Due to various additional constraints such as available swap, kernel address space usage, memory fragmentation, and VM overhead, in practice the limit can be much lower. On most modern 32-bit Windows systems the maximum heap size will range from 1.4G to 1.6G. On 32-bit Solaris kernels the address space is limited to 2G. On 64-bit operating systems running the 32-bit VM, the max heap size can be higher, approaching 4G on many Solaris systems.

In nutshell:
Theoretically : 4GB
Practically:  1.4 to 1.6GB

Tuesday, October 7, 2014

Where can I find eclipse preferences stored files ?

Eclipse stores all the preferences in the preference configuration files. This you can find in the below eclipse workspace location.


Say for example, jre configuration will be stored in the "org.eclipse.jdt.launching.prefs" file.

Friday, September 19, 2014

How to contribute a new menu to the workbench ?

Eclipse exposed a mechansim to contribute a new menu through "org.eclipse.ui.menus" extension and locationURI.
Requried extension: org.eclipse.ui.menus

Below example will contribute a new "Cloud" menu to the eclipse workbench, and this will contain a "Upload" menu item.


Command contribution to upload action:


Handler contribution to upload action:


Wednesday, September 17, 2014

UI Toolkits and Multi-threaded environment

How to get active perspective in Eclipse

Active workbench page will have getPerspective() this will return the IPerspectiveDescriptor

IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null) {
IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
if (activePage != null) {
IPerspectiveDescriptor perspective = activePage.getPerspective();
if (perspective != null) {
String id = perspective.getId();
//This is your active perspective

visibleWhen on toolbar in Eclipse

I have added visibleWhen directly under toolbar, look like platform is not respecting visibleWhen for toolbar.

This is how I defined the extension:

             label="Charm bar">

visibleWhen has no effect on toolbar

Workaround for this problem is, adding visibleWhen for each command. 
By adding visibleWhen on each command, toolbar is automatically getting disappeared if there are no visible elements

In my case, I want to add add a righside trim toolbar with some tool items. But I wanted to show this only in my perspective 'KKPerspective'.

             label="Charm bar">


Tuesday, September 16, 2014

Conventions for naming git branches for your development

Some practices which I follow for naming git branches.

If you are working on sprint/agile development, you might have planned certain activities for each sprint.

let's say, every sprint development is for 1 month,so for every sprint we can maintain different branches as mentioned below.

Example: In Development mode
Sprint 1  =>  Branch name: dev-1.0.1

here, dev-<Major version>.<Minor version>.<Sprint version>

While handing over your work to QA team, we can promote this branch to QA branch.

Example: In QA mode
dev-1.0.1 will become qa-1.0.1

If you are providing builds one top of dev branches.
Example: For sprint 1 on dev branch

Here, <pluginname>_<<branch name>.<build number>>.jar

on QA builds generation,

If many people are working on sprint on various features, then we can create a different branch for each feature(ex: dev-1.0.1_explorer), once the feature is stabilized then we can merge this with the main sprint branch i.e dev-1.0.1

Monday, September 15, 2014

Eclipse Plugin name and package name conventions

I will follow below conventions for naming any new plug-in which I am contributing.

Plug-in names should follow the standard Eclipse Naming conventions. That means that,
(i)   The project name on disk(Plug-in name) is the same as the plug-in id and
(ii)  Plug-in packages should start with plug-in name.
(iii) Don’t mix generated code plug-in and implementation plugins<component name><major component name>.<minor component name>

 Examples:   => Implemented code plug-in    => EMF model based generated code plug-in

Package Names:  => Plug-in name/Plug-in id

Eclipse Resources:

java.lang.OutOfMemoryError: unable to create new native thread

One of the developer reported "java.lang.OutOfMemoryError: unable to create new native thread" while working with eclipse on his application.

Below is the error log.
java.lang.OutOfMemoryError: unable to create new native thread
                at java.lang.Thread.start0(Native Method)
                at java.lang.Thread.start(Unknown Source)
                at java.lang.ref.Finalizer$ Source)
                at Method)
                at java.lang.ref.Finalizer.forkSecondaryFinalizer(Unknown Source)
                at java.lang.ref.Finalizer.runFinalization(Unknown Source)
                at java.lang.Runtime.runFinalization0(Native Method)
                at java.lang.Runtime.runFinalization(Unknown Source)
                at java.lang.System.runFinalization(Unknown Source)
                at org.eclipse.ui.internal.ide.application.IDEIdleHelper$


This is what i can think why he encountered with this issue.

User is running on 32 bit machine with 
Since he is running on 32 bit machine, you need to allocate –Xmx and -XX:PermSize carefully. Since 32 bit machines can address maximum of 4GB address space.

Since we allocated -Xmx is 1024m and -XX:PermSize is 512m, there is very less space is remaining to create a new Java native threads by OS.

To make it work, reduce -XX:PermSize to 256m and –Xmx to 512m(unless 1024 is required).

Expanding a trim view Vertically in programmatic way in Eclipse e4

Generally, If you have minimized a view, It will go and add it to the trimbar as shown on the left hand side.

If you click on tool item from the trimbar, it will show as a fast view. Means, It won't expand completely either in horizontally or vertically. But, user can do this by changing the orientation as show on the image.

To achieve this programmatically, we have to use Eclipse e4 workbench presentation engine component

For Vertically:

For Horizontal:

WorkbenchPartReference myView = page.findViewReference("myviewid");
MUIElement element = ((WorkbenchPage) page).getActiveElement(myView);

WorkbenchWindow activeWorkbenchWindow = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
MWindow window = activeWorkbenchWindow.getModel();
if (window != null) {
EModelService modelService = window.getContext().get(EModelService.class);
if (modelService != null) {

By adding a element tag sets the behaviour for a particular element.

From Eclipse, "This tag can be applied to an element as a hint to the renderers that the element would prefer to be vertical. For an MPart this could be used both as a hint to how to show the view when it's in the trim but could also be used when picking a stack to add a newly opening part to. It could also be used for example to control where the tabs appear on an MPartStack."

How to minimize a view programmatically in Eclipse e4 versions/ Adding a view to the trimbar

Below snippet can be used to minimize a view.

IViewPart part = page.showView("com.kk.views.showtasks");
if (part != null) {
 IWorkbenchPartReference myView = page.findViewReference(viewid);
MUIElement element = ((WorkbenchPage) page).getActiveElement(myView);
WorkbenchWindow activeWorkbenchWindow = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
MWindow window = activeWorkbenchWindow.getModel();
if (window != null) {
            EModelService service = window.getContext().get(EModelService.class);
if (service != null) {


More important thing here is,

When above code gets invoked, MinMaxAddon.minimize(..) will be invoked internally to minimize a view. Minimized view will be added as a toolbar item to the trimbar.

MUIElement element = ((WorkbenchPage) page).getActiveElement(myView);
Here element is PartStack element, that means all the elements(Parts) which are there in the partstack will be minimized.

How to add right trimbar/side bar in eclipse

This can be achieved through "org.eclipse.ui.menus" extension point with the locationURI as "toolbar:org.eclipse.ui.trim.vertical2"

             label="Eclispe rightside trimbar">

toolbar:org.eclipse.ui.trim.vertical2 -> will be for used for Right trimbar

We can find all these uri identifiers in in eclipse org.eclispe.ui.workbench plugin

 /** Top Left Trim Area */
public final static String TRIM_COMMAND1 = "toolbar:org.eclipse.ui.trim.command1"; //$NON-NLS-1$
/** Top Right Trim Area */
public final static String TRIM_COMMAND2 = "toolbar:org.eclipse.ui.trim.command2"; //$NON-NLS-1$
/** Left Vertical Trim Area */
public final static String TRIM_VERTICAL1 = "toolbar:org.eclipse.ui.trim.vertical1"; //$NON-NLS-1$
/** Right Vertical Trim Area */
public final static String TRIM_VERTICAL2 = "toolbar:org.eclipse.ui.trim.vertical2"; //$NON-NLS-1$
/** Bottom (Status) Trim Area */
public final static String TRIM_STATUS = "toolbar:org.eclipse.ui.trim.status"; //$NON-NLS-1$

How to get Eclipse EModelService from workbench ?

WorkbenchWindow activeWorkbenchWindow = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
MWindow window = activeWorkbenchWindow.getModel();
if (window != null) {
EModelService modelService = window.getContext().get(EModelService.class);

//your calls

Thursday, September 11, 2014

eclipse -clean option in mac os x

1. Go to eclipse directory
2. Find Eclipse Application
3. Right click on  Eclipse Application
4. It will show "Show Package Contents" menu option
4. Click on Show Package Contents
5. Go to Contents folder
6. Go to MacOS folder
7. Open the terminal
8. Drag the MacOS directory to terminal for change directory(ex: cd <macos directory>)
8. execute this " ./eclipse -clean"

eclipse.ini file in Mac os x

1. Go to eclipse directory
2. Find Eclipse Application
3. Right click on  Eclipse Application
4. It will show "Show Package Contents" menu option
4. Click on Show Package Contents
5. Go to Contents
6. Go to MacOS
7. Look for eclipse.ini file

Monday, September 8, 2014

Unsupported major.minor version 51.0

java.lang.UnsupportedClassVersionError happens because of a higher JDK during compile time and lower JDK during runtime.

51.0 in "Unsupported major.minor version 51.0" represents that, .class file generated with JDK 1.7 and but you are trying with run with(runtime) with lower version of it.

Below are the version numbers and compatible JDK's.

J2SE 8 = 52,
J2SE 7 = 51,
J2SE 6.0 = 50,
J2SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45

To resolve this issue, make use of same version during the compile time and run-time.

Example: You would have generatd jar file with jdk 1.7 and but you are trying to run that jar using JDK 1.6 eclipse, this leads to above error.

Saturday, August 23, 2014

What is eclipse workbench ?

A workbench is the root object for the Eclipse Platform user interface.

A workbench has one or more main windows which present to the end user information based on some underlying model, typically on resources in an underlying workspace. A workbench usually starts with a single open window, and automatically closes when its last window closes.

Each workbench window has a collection of pages; the active page is the one that is being presented to the end user; at most one page is active in a window at a time.

Each workbench page has a collection of workbench parts, of which there are two kinds: views and editors. A page's parts are arranged (tiled or stacked) for presentation on the screen. The arrangement is not fixed; the user can arrange the parts as they see fit. A perspective is a template for a page, capturing a collection of parts and their arrangement.

The platform creates a workbench when the workbench plug-in is activated; since this happens at most once during the life of the running platform, there is only one workbench instance. Due to its singular nature, it is commonly referred to as the workbench.

Friday, August 22, 2014

How to get eclipse workspace project path ?

public String getProjectPath(IProject project) {
   String absolutePath = project.getLocation().toFile().getAbsolutePath();
    return absolutePath ;

Converting Java io File to eclipse IFile resource

Below function will convert File to eclipse IFile resource.

public IFile convert(File file) {
   IWorkspace workspace= ResourcesPlugin.getWorkspace();  
   IPath location= Path.fromOSString(file.getAbsolutePath());
   IFile ifile= workspace.getRoot().getFileForLocation(location);
 return ifile;


This works only when resource exists with in the workspace.

Accessing the resources outside the workspace:

Debugging web applications - fiddler

Configuring Permgen parameter for Tomcat

Wednesday, August 13, 2014

git pull: Couldn't reserve space for cygwin's heap, Win32 error 0

When I tried to pull the code from git, it took so long and finally it said "Couldn't reserve space for cygwin's heap, Win32 error 0"

There are various discussions which I found over web. But the first thing which i tried was "restarting my windows system" and it worked for me!!


Tuesday, August 12, 2014

Opening eclipse editor or view in the dialog programatically

We can open eclipse editor or view in the dialog by using the Eclipse e4 model services. This is also called detaching the editors/views from the eclipse workbench.

For this, you need to have e4 workbench plugin and it provides org.eclipse.e4.ui.workbench.modeling API services.

IWorkbench workbench = ActivatorPlugin.getDefault().getWorkbench();

//get editorpart somehow which you wanted to open it.
EditorPart openEditor = /*IDE.openEditor(workbench.getActiveWorkbenchWindow().getActivePage(), module, MyEditorID, false); */

//get editor site
IWorkbenchPartSite site = openEditor.getSite();

//get model service for editor site
EModelService modelService = (EModelService) site.getService(EModelService.class);
MPartSashContainerElement  mpartService = (MPart) site.getService(MPart.class);

//invoke detach on model service with coordinates.
modelService.detach(mpartService, 100, 100, 700, 700);

For view:

//Get view part
IViewPart view = workbench.getActiveWorkbenchWindow().getActivePage().findView(MyPerspective.ExplorerView_ID);
//get site for view
//invoke detach


Saturday, August 2, 2014

Hide toolbar in eclipse programatically

You might want to remove eclipse toolbar completely in your Eclipse RCP product to make use of that space or you might not have any useful toolbar actions which are specific to your product.

This how you can remove programatically.

private void hideCoolbar() {
try {
IHandlerService service = (IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
if (service != null)
service.executeCommand("org.eclipse.ui.ToggleCoolbarAction", null);
} catch (Exception e) {
KEditorPlugin.logError("Unable to hide the eclipse toolbar.",e);

Hide tool bar in eclipse

In eclipse 3.8 version and earlier, you can find "Hide Toolbar" option on the right click of eclipse toolbar itself. This will hide the complete toolbar.

In Eclipse e4 versions, you can find this option in on the Eclipse toolbar Window menu.
Window -> Hide Toolbar

To enable again,
Window -> Show Toolbar

Thursday, July 31, 2014

Wednesday, July 16, 2014

Executing batch file through Java

Batch file has to perform below actions.

1. Change the directory for a given path
2. start the node sever
3. Exit the command window

>cd D:\nodev0.18
>node app.js console

FileName: Myfile.bat
Batch file defined with variable arguments like below.

cd %1
%2 app.js console

Java code for invocation:
String executePath = "cmd /c start Myfile.bat"

Executing windows commands through java

I wanted to start the node server programmatically.
>node app.js

Using Java:

String executePath = "cmd /c start node app.js"


Removing eclipse view title bar tab

public class Perspective implements IPerspectiveFactory {
  public void createInitialLayout(IPageLayout layout) {      
    String editorArea = layout.getEditorArea();

    layout.addStandaloneView(View.ID, false, IPageLayout.LEFT, 1.0f, editorArea);      

A standalone view's title can optionally be hidden. If hidden, then any controls typically shown with the title (such as the close button) are also hidden. Any contributions or other content from the view itself are always shown (e.g. toolbar or view menu contributions, content description).


Thursday, July 3, 2014

Setting "java.library.path" programmatically


I have 6 dll files in my eclipse plug-in under lib/win64 folder. I wanted to load them dynamically during the launch of eclipse.

I have tried the eclipse way of bundling native-code in the plugin manifest, but somehow i could not achieve. So I have to go by manipulating the system path.

Eclipse bundle-native code mechanism:

try {
     //eclipse call
Bundle bundle= getBundle();
URL fileUrl = FileLocator.toFileURL(FileLocator.find(bundle, new Path("/"), null));
String location = fileUrl.getFile();
String libPath = location + "lib/win64";
File file = new File(libPath);
System.setProperty("java.library.path", file.getAbsolutePath());
Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
fieldSysPath.setAccessible( true );
fieldSysPath.set( null, null );
} catch (NoSuchFieldException e) {
} catch (SecurityException e) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
} catch (IOException e) {

The Classloader has a static field (sys_paths) that contains the paths. If that field is set to null, it is initialized automatically. Therefore forcing that field to null will result into the reevaluation of the library path as soon as loadLibrary() is called


Generate java classes from xsd using JAXB

We can use JAXB to do this job.

More info:

JAXB bundles with JDK kit from 1.6 onwards.

You can find a service called 'xjc' in the <jdk directory>/bin folder.

C:\Program Files\Java\jdk1.6.0_30\bin>xjc D:\Modules\functionalModules.xsd
parsing a schema...
compiling a schema...

Java classes will be generatd with in the 'generated' folder of java bin directory.

Friday, May 16, 2014

Removing untracked files from local git branch

We can use git clean command to remove all untracked files from your local working branch.
> git clean -f

This will remove all untracked files forcefully.

To remove even the untracked directories which are present in the local branch.
>git clean -f -d

Wednesday, May 7, 2014

ObjectAid UML eclipse plug-in for UML class diagrams

You can download from:

Update site:

Repository ZIP file:

What all you can do with this ?
Class diagrams - Free
Sequence diagrams – Commercial license required

Get started:

How good is this ?
I found it’s very simple and clean tool without any hassles. You need to get started with one class and keep adding the references, it will build the class diagram nicely based on the references it has.

What is not possible ?
1.       I don’t see a way to generate class diagram for whole plug-in
2.       I don’t see a way to generate class diagram for bunch of classes/package at a time.
3.       Relationships is not so clear.
4.       I don’t find a way to create a new relationship or modify the existing one.

Tuesday, May 6, 2014

Eclipse is too slow, they try out these options

Are you feeling your eclipse is slow ? And, is it taking lot of time to open your eclipse ?

Based upon my experience I have put down some points that would help you out.

1.       Try to open your eclipse in clean mode.
    Command:  > eclipse –clean

What is does ?
Cached data used by the OSGi framework and eclipse runtime will be wiped clean. This will clean the caches used to store bundle dependency resolution and eclipse extension registry data. Using this option will force eclipse to reinitialize these caches.

2.       Configuring suitable heap memory size in eclipse.ini file. Verify max heap size parameter (Xmx) and configure based on the application need.
Example:  -Xmx1024M

This is where your java objects will be stored.

3.       Make sure to configure sufficient permgen size in eclipse.ini file. Configure based on the your application need.
 Example: -

This is where you classes and method definitions will be loaded after starting your application

4.       Close unnecessary projects in your workspace.
Example: You might have 10 plug-ins in your eclipse current workspace, but you might be using or working on only 2 plug-ins, and that work independent of other plug-ins.

5.       Try to avoid force closing eclipse.  It takes lot of time to initialize the previous state of eclipse based on the history indexes.

6.       Don't enable all third-party code enforcement tools by default.

  • Find bugs - run based upon need.
  • Google code analytics
  • Check style

 7.       You can remove Project build automatically option in eclipse and enable only based on the need.

8.  Remove automatic updates for eclipse plug-ins and third party plug-ins.
    You can find “Automatically find new updates and notify me” option in your eclipse.

8.       Once in a while try to switch all your plug-ins/projects in to new workspace and work.

As a programmer:
  • Don't keep so much of code in your Activator start() methods
  • Minimize the number of classes in the each plug-in
  • Don't run too many background processes in your application.
  • Don't create too many threads at a time. Make sure no.of threads should be less than or equal to number of processor cores in the system.

java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM

This problem occurs when we are trying to load 32 bit swt libraries (ex: swt.jar) on 64 bit Java

Example: When you are trying to open your 32 bit eclipse with 64 bit JRE, you will be facing this issue.

Another case would be, you would have packaged 32 bit swt libraries with your application, but you are trying to run your application on 64 bit JRE.

How to resolve ?
Make sure you will be using the same version either 32 bit/64 bit for eclipse and Java.

java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM
at org.eclipse.swt.internal.Library.loadLibrary(
at org.eclipse.swt.internal.Library.loadLibrary(
at org.eclipse.swt.internal.C.<clinit>(
at org.eclipse.swt.widgets.Display.<clinit>(
at org.eclipse.ui.internal.Workbench.createDisplay(
at org.eclipse.ui.PlatformUI.createDisplay(
at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay(
at org.eclipse.ui.internal.ide.application.IDEApplication.start(
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(
at org.eclipse.equinox.launcher.Main.basicRun(
at org.eclipse.equinox.launcher.Main.main(

Finding a .log file in eclipse

Your .log file is located in a .metadata folder in your current workspace directory.
The following is the path if you are working on the default workspace.


Windows : C:\Users\username\Documents\<Studio Workspace>\.metadata\.log

Mac OS X: ~/Documents/<Studio Workspace>/.metadata/.log

Wednesday, April 30, 2014

Wednesday, April 16, 2014

Writing git log output to a file

$ git log --since="04/07/2014 20:37:53" --no-merges  > C:\test.log

It will write generated git log from the specified date and time without including merges to a test.log file.

Monday, April 7, 2014

Creating an executable JAR file for SWT Plug-in - Runnable JAR

You would have developed a small utility application, and now you wanted to create an executable JAR for that application.
Basically, end user should be able to launch the application by just double clicking on that.

Eclipse provides an option called “Runnable JAR” in the export menu items to perform this.

This will generate Plugin_Refactor_x86_1.0.jar file, including with all the required swt jars. 

Since swt native jars will be platform specific, we need to generate 32 bit or 64 bit files separately.

How to check Installed Java is a 32 bit or 64 bit version ?

If you have installed JDK, Java would have registered in the system environment variables.

Go to command prompt and type “java –version”

C:\Users\kh1205>java -version
 java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)

If it’s a 64 bit Java, you will be finding “64-Bit Server VM” in the above line.

If it’s a 32 bit java, you will be finding “Client VM” in the above line.

I have another JDK configured in my system, for which I wanted to check java version.
For example, other version of java is available in the location “C:\Program Files (x86)\Java\jdk1.6.0_31

C:\Program Files (x86)\Java\jdk1.6.0_31\bin>java -version
 java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)

“Client VM” in the last line tell you that,  JDK is a 32 bit version.

Friday, March 28, 2014

Microsoft visio for UML

Microsoft visio supports UML diagrams.

  • Class diagram
  • Sequence diagram
  • Use Case diagram
  • Activity diagram
  • State diagram

Download trial version @

You can download UML2.5 stencils @