I am just trying to make a sample desktop application in Eclipse through which I am trying to prove/learn for myself and clear my concept that if we write our own class loader then a class would have only a single instance.
No. Each class will have exactly one instance if that's how often an object of that class gets instantiated. As was said before, class loaders load classes, not objects. They're not a solution to this problem (to the contrary, they can make it significantly harder).
I read somewhere that for ensuring that a class to be truly Singleton we have to write our own class loader to load our Singleton class. Is it true if not then please so clear my concept.
It doesn't matter how many classloaders you have, or if you have written them yourself. If you want to make sure that there's only a single instance of a class, then you must ensure that it gets instantiated no more than a single time, and that only a single classloader does that.
Is this applicable for desktop applications or for web applications ?
This is true in general. But servlet containers use more classloaders than desktop applications, so you have more opportunities to instantiate a class more than once, if you're not careful about which classloader has access to the class.
And what is the solution which is prescribed for this.
I'd start by learning a lot more about classloading.
This is a good introduction. Once you know the differences between the boot classloader, the extensions classloader and the system classloader you can start to think about ways how to avoid loading a class more than once.
[ September 02, 2008: Message edited by: Ulf Dittmer ]