Hate to be the bearer of bad news, but if you've run any program like this on your personal machine, and made it accessible to the outside world, you realistically have to assume that you've had data stolen and/or your machine has been compromised.
1) Can hackers compromise my iMac because of my naive server program? If so, what should I modify in my code to prevent it?
If you're writing anything like this, you have to assume the answer is yes. There's a reason why many, myself included, say never to roll your own security - industry standard tools, algorithms and frameworks have generally been tested and hardened in real world use over a number of years, and even they have security flaws (sometimes critical) that are revealed from time to time.
Even using such a hardened, industry standard solution though, I'd never run something like this on a personal machine unless it was behind some other layer of protection (such as a VM.)
2) What mechanisms in my code are the weak links?
This is the wrong approach - I could maybe tell you a dozen massive holes if I saw the code in its entirety, and there could still be hundreds more. That wouldn't make it secure, and you shouldn't assume that it is. You also need to consider the security of the platform that you're running on (everything from the Java VM down to the OS), so you could write a completely water tight application and still be vulnerable.
In any case, even ignoring all the above. I couldn't say. You haven't provided the code (even in the Stackoverflow question, the code clearly isn't a complete, self contained example - there's method calls / objects missing.)
However, just for the sake of playing along with what you have posted, you never actually check if you're logged in before doing:
DrawData dat=(DrawData)acceptUserData();//this reads objects
//from the socket inputstream
...which really smells of something not being right to me.
3) Is it possible for a hacker to access my iMac just by knowing the static ip?
If this program is running on it, and you've punched a hole in the firewall? Sure, I'd say you have to assume that people can, and have accessed your machine. If you've got passwords, sensitive data or anything else of the like on there, you'd be wise to change all of it immediately.
In the future, if you really want to experiment around with running (likely) insecure programs you've just written, then at least spin up a cheap VM and run it on that instead - that way if it gets compromised, there's not as much to lose.