Apple has said its computers were attacked by the same hackers who targeted Facebook.
The iPhone-maker said a small number of its machines were affected, but added there was "no evidence" of data theft.
Last week Facebook said it had traced a cyber attack back to China which had infiltrated employees' laptops.
Apple said it would release a software update to protect customers against the malicious software used in the attack.
In a statement, the Cupertino, California-based firm said: "Apple has identified malware which infected a limited number of Mac systems through a vulnerability in the Java plug-in for browsers.
"The malware was employed in an attack against Apple and other companies, and was spread through a website for software developers.
"We identified a small number of systems within Apple that were infected and isolated them from our network. There is no evidence that any data left Apple.
"We are working closely with law enforcement to find the source of the malware."
News of the hack comes as a US-based cyber security firm claimed to have pinpointed a specific building in Shanghai that was being used to house one of the world's "most prolific cyber espionage groups".
Mandiant said Unit 61398, part of the country's People's Liberation Army, was believed to have "systematically stolen hundreds of terabytes of data" from at least 141 organisations around the world.
China denied hacking and questioned the validity of Mandiant's report.
Apple said it had taken measures to protect users from vulnerabilities in Java, a widely-used programming language that was found to have serious security flaws.
"Since OS X Lion, Macs have shipped without Java installed, and as an added security measure OS X automatically disables Java if it has been unused for 35 days," the company said.
"To protect Mac users that have installed Java, today we are releasing an updated Java malware removal tool that will check Mac systems and remove this malware if found."