Then are the both grammatical? Is there any differences in meaning?
They're both grammatically correct although we rarely use the verb "to determine" in the present tense in this way. When talking about someone's decision to do something, it's more likely to be in the past tense.
When I failed my first set of exams, I determined to try harder at the next set.
I should add that we would be more likely to say "I decided to" or "I resolved to" in that example. Alternatively, we would say "After failing my first set of exams, I was determined to do better in the next set".