I got the result that is consist with references in fisrt case. Is there anything wrong in 2nd way?
Both are wrong. In the first case you are missing a 2 in both terms (still giving the same equation if you put the variation to zero). In the second case you missed a 2 only on the first term.
Thank you. I see.
I should consider another Kij here.
Yes, you cannot vary Kij independently of Kij.
Separate names with a comma.