I have gone through the previous thread on the same topic
After reading that i tried to use the same code. I am very new to Eclipse plugin development. I tried to see the given example links but couldn't find the correct thread.
I have a similar requirement. I tried to develop a plugin following this link
Should i compulsory develop a plugin or is there any way where i can run it from java main method.
Thanks, Vamsi
Basically, you have to write an Eclipse plug-in, as the suggested code re-uses existing features only available in an Eclipse plug-in environment.
For the referenced code to work, you have to maintain a plug-in with the dependencies org.eclipse.core.resources plug-in, and you also have to provide some functionality to execute this code (e.g. a platform command, as in another the mentioned vogella.de tutorial.
In theory, it might be possible to do it in plain Java code, but in that case it would make more sense to do it by directly editing the metadata files - and that is a way I do not recommend.