I want to upgrade my jdk on a centos server, after some simple searches i found some solutions.

From this link, you can see that the instructions are simple:
[jdk 7 installation guide for centos][1]

-install your chosen jdk from rpm package or from source

-possibly choose some alternatives 

-check that the new version installed (`java -version`)

The first two steps above, I easily completed, but in check version step i get this error:

    Error occurred during initialization of VM
    java/lang/NoClassDefFoundError: java/lang/Object

i have also checked `alternatives --config java` and symbolic links.

i have also tried `which` command to find out what java is actually running and this was the link directoins.

`/usr/bin/java -> /etc/alternatives/java -> /usr/java/jdk-1.8.0_40/bin/java`

the weird thing is that when i run `/usr/bin/java -version` it is OK and it returns the version but when i run `java` without any prefix i got that error.

So what could the problem be?

  [1]: http://www.if-not-true-then-false.com/2010/install-sun-oracle-java-jdk-jre-7-on-fedora-centos-red-hat-rhel/