Santa Clara, Calif.-based Sun (NASDAQ: JAVA) employs roughly 2,200 at its Broomfield offices.
The deal -- which is expected to be completed this summer -- appears to end a drawn-out attempt to sell Sun, which earlier in the year had unsuccessful negotiations with International Business Machines Corp. (NYSE: IBM) that reportedly broke down at the last minute.
The companies valued the deal at $7.4 billion, including cash and debt. At $9.50 a share, the price is a 42 percent premium over Sun's closing price on Friday.
Redwood City, Calif-based Oracle (NASDAQ: ORCL) expects to add at least 15 cents to its bottom line from the deal in the first year. The company expects to add $1.5 billion to operating profit in the first year and more than $2 billion in the second year.
"The acquisition of Sun transforms the IT industry, combining best-in-class enterprise software and mission-critical computing systems," said Oracle Chief Executive Larry Ellison in a statement.
Oracle uses Sun's Java software and language already in some of its products including its Fusion Middleware business and it uses the Solaris operating system for its database business.