Do you think it's bad that I used my friend's credit card when I had to buy something but didn't have enough money for it?
Yes, if you took it without permission it's bad. Why would you do that?
I needed a book for my class but I didn't have any money.
If you didn't have the money, then you can't make the purchase, simple as that. That does not make stealing from your friend any more legit.
I'll pay him back for it when I get money, I just needed the book right now.
You could have asked your parents to borrow the money, especially since it's for something for your education. I know you'll pay him back, but taking his credit card without asking is wrong. Make sure you apologize for what you did.