Depends on what kind of online game you want to program. If you want a massive multiplayer game like ultima online look more at c++. A smaller mud, chess, battleship could be implemented in Java nicely though.
Programming a multiplayer game (at least in C++) is definitely harder than a normal, single player game. With multi, you have to account for synchronization of players and a multitude of other difficulties. Also, if you are going to write a multiplayer game, make sure to have good knowledge of TCP/IP. Whichever way you choose, good luck!