I want to know can symmetric keys be used to sign a message ? We can encrpyt using the shared secret key. Also when symmetric key is used for signing , what API can be used in J
Symmetric algorithms can't give the non-repudiation property that asymmetric signature schemes give, i.e. the receiver of a message can't prove that he didn't create the message themselves, as they have to know the scheme.
That said, a message authentication code (MAC) can give you what you want: Both sender and receiver have a shared key, the sender calculates a MAC with the secret and appends it to the message, and the receiver calculates the same MAC and compares it with the received message.
While the most often used MAC type (HMAC) is based on hash functions, there are also ones which are based on a block cipher like AES, like CBC-MAC (this is like CBC, but with zero initialization vector and using only the last block as output). (As said by noloader, CBC-MAC is not the most secure way of doing this, use other modes.)
You should use message authentication in most cases where you use encryption, as many encryption schemes are vulnerable to chosen-plaintext attacks.
In Java, a MAC can be calculated (and checked) by using the javax.crypto.Mac class.