Mahesh's example omitted a crucial point: clone() returns an Object, and you have to cast the returned object to the correct type:
Cloneex dup = (Clonex) ex.clone();
Now, there are three other problems with the example: you'll get a CloneNotSupportedException when you run it. To make something cloneable, you have to declare that the class "implements Cloneable". If you don't, clone() will refuse to work. You generally also need to override clone() to make it public, because the one in Object is protected.
Finally, your variable "x" is static. A single copy of a static variable is shared by all instances of a class, so this isn't a very interesting test of cloning as it stands. To show that two objects are the same, you'd want to make that variable and method non-static, so they belong to the individual instances.