I cannot execute Java program in XCode for Mountain Lion 10.8.2. Please help me how to execute a Java program.
Do you have a particular error or message or diagnostic or issue, or something that's particularly wrong with Xcode? If installed, Java does work, and Java applications can be invoked.
Background: Java was deprecated from OS X a while back, and Java itself was removed from the default OS X 10.8 installation.
Given that Java is now an add-on for OS X, you'll want to check with Oracle — the owner of Java — for OS X kits and tools.
I don't know off-hand if Xcode still particularly supports Java (it was pretty weak, when last I checked), but I'd expect you'll be using makefiles for the work, and I'd also suspect that whatever Java support remains in Xcode will probably be going away in some future version of Xcode. (If support hasn't already disappeared. You may be using bash build scripts and makefiles to deal with Java now, or going forward.)
If you don't have access to the Apple developer forums and the discussions of tools available there, then the archives of the Apple Java-Dev mailing list can be a good spot to look for existing discussions, and to post questions related to Java development on OS X.