Oracle (ORCL) said Monday that it will buy Sun Microsystems (JAVA) for $9.50 a share in cash, or about $5.6 billion excluding debt, in a deal that plunges Larry Ellison & Co. into the hardware market.