You can press them out using appropriate size sockets and a bench vise. Use a socket larger than the u-joint cup diameter as the receiver and one just under the cap diameter as the pusher. This can be somewhat rough on a bench vise, though, especially if it's a smaller one. Another option (this is how I do it) is to use a balljoint press. Same basic concept, but you're using a C frame press designed to handle the loads involved. If you don't have one, you should be able to rent one from your local parts store.
Tip; when you install the new joints, put a light coat of antiseize on the outside of the cups. This will make installation easier, and if you ever have to service it again, diassembly as well.