Oracle Corp. (ORCL) will buy Sun Microsystems Inc. (JAVA) for $7.4 billion, calling Sun's Java "the most important software" it has ever acquired.

Earlier this month, Sun's talks to sell itself to International Business Machines Corp. (IBM) unraveled, raising new questions about the prospects for the company and Chief Executive Jonathan Schwartz, who has been under pressure to come up with an alternative for the struggling computer maker.

The Silicon Valley icon has seen slumping sales of its servers and posted losses in three of its last four quarters.

The deal values Sun at $9.50 a share, a 42% premium to Friday's close. Sun's shares were recently up 27% at $8.50 while Oracle fell 4.5% to $18.20.

Oracle expects the acquisition to add $1.5 billion to operating profit in the first year and more than $2 billion in the second year. President Safra Catz said that would make the Sun deal more profitable in per-share contribution in the first year than its recent acquisitions of PeopleSoft, Siebel and BEA combined.

Oracle's Fusion Middleware business is based on Sun's Java language and software, and Oracle said it could now ensure continued investment in the technology. It will also acquire the Solaris operating system, the leading platform for its database business, which is its largest.

Sun's board unanimously approved the deal, which is valued at $5.6 billion net of the company's cash and debt and is expected to close this summer.

Schwartz's status was described by some as precarious if he couldn't complete a sale of Sun. Schwartz, who took over as CEO in 2006, has made some progress in shifting Sun's focus toward software, but the company still gets a big chunk of its revenue from the line of servers that has faced slowing sales recently.

-By Kerry E. Grace, Dow Jones Newswires; 201-938-5089; kerry.grace@dowjones.com