The court said that Microsoft has 90 days to change any products it ships that fail to pass Sun's compatibility test for Java.
Palo Alto-based Sun Microsystems filed suit against the Redmond, Wash.-based Microsoft last October, seeking $35 million in damages for allegedly developing and distributing a Windows-only form of the language.
In granting a preliminary injunction, U.S. District Judge Ronald Whyte said the lawsuit was likely to go forward on merit.
"While this case proceeds through the court, we'll continue to use our enormous energy in the marketplace as will the other companies that are the cornerstones of the Java technology industry to deliver high performing Java technology that outperforms Microsoft's incompatible technology," said Alan Baratz, president of Java Software at Sun Microsystems.
Microsoft spokesman Jim Cullinan said the company would comply with the order while it reviews its legal options.
"We are disappointed in Sun's shortsighted legal strategy which we believe limits choice for customers and developers," Cullinan said.
In the lawsuit, Sun Microsystems accused Microsoft of trying to make it impossible for Java to become a universal programming language.
But evidence from Microsoft indicates that at least some at Sun thought the contract between the two companies allowed Microsoft to use Java in that way.
Sun's accusations are also a key part of the Justice Department's litigation against Microsoft in the antitrust trial in Washington, D.C.
Java, introduced by Sun Microsystems in 1995, potentially allows developers to write a software program once and have it run on a wide variety of computers, regardless of the underlying operating system.
©1998 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed