There are many Java Decompilers which can decomile .class file to .java file revealing the source.

Is there any way to prevent this reverse engineering ?

Like in .Net framework, once .dll or .exe is built, noone can reach to source code.

?:S

There are many Java Decompilers which can decomile .class file to .java file revealing the source.

Is there any way to prevent this reverse engineering ?

Of course. Provide a web service rather than a standalone application.

Like in .Net framework, once .dll or .exe is built, noone can reach to source code.

?:S

Wrong.

Yes that's one of the way.
But in case if i don't have option of web service. If I can't give SaaS. I have to handover .class files to customers.
Then in such a case what to do ?

Firstly languages such as Java do not offer such "consealing" feature cause they are not meant to be used that way. Secondly as masijade has rightly pointed out executables are not all safe. Though it requires good knowledge of such they can be broken too.
Read about obfuscation and what it does in order to make your code "unfriendly" or harder to understand to others. But this too isn't 100% safe rather quite far from it.

The only way to protect such source code is through the use of appropriate licenses that prohibit others from using your code in a way different from the one you intend them to use.

This has been well mentioned by the then moderator and current super mod s.o.s and masijade in a previous thread, you can find it if you want.

This article has been dead for over six months. Start a new discussion instead.