This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
i installed and executed the command sudo update-alternatives --config java
and javac and java commands are worked properly
and i compiled my file by using javac Welcome.java compiled fine but whent i am trying to run java Welcome i am getting following exception
Exception in thread "main" java.lang.UnsupportedClassVersionError: Welcome : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.security.AccessController.doPrivileged(Native Method)
Could not find the main class: Welcome. Program will exit.
You don't necessarily have to uninstall anything. You can just set your PATH environment variable so the appropriate one comes first, or create shell scripts, functions, or aliases to invoke the desired executables by their respective full paths.
If you do want to uninstall, it depends on your flavor of Linux. Centos and some others have yum. Red Hat has rpm. Ubuntu has apt. I've used these for installing and upgrading. I don't know if they have uninstall options as well, but I'd assume so. There may also be a GUI-based tool on your system for maanging installed software. Or just executing rm -rf on the appropriate directories may be sufficient, but use caution when doing that!