I tried to save password as hash values. I used sha512 with salt. When i try to verify the password seems it generate different hash values .I am generating random salt using SecureRandom class in java.
Don't roll your own crypto. Use a key derivation function to generate password hashes for you, not your own hash+salt combination.
Having said that, if this is for educational purposes go right ahead, as long as it doesn't end up in production somewhere.
You are likely generating a new salt during the validation step. Don't. Use the same salt you generated when you hashed the original password. If you need more help with this, you'll have to show us your code though.
yes, it was issue of the salt since salt saved as a String it may changes the content. I saved the salt as a byte array and now it is ok. I have one more question . If i use pepper as another salt where it must be saved. in the code or config file ?
It doesn't matter how you add it. You can add it by concatenating the strings together, or you can add it by creating a byte array and filling it with the binary data of the password, salt and pepper in succession. Remember that most crypto functions work on byte arrays, so you need to make sure that whenever you convert your strings to binary, you do it with a fixed known encoding.