A D.C. Superior Court judge has ordered District Mayor Marion Barry and city housing officials to provide heat and hot water immediately in four rundown public housing projects where some tenants said they have lacked these services for four years.

Judge Harriet Taylor's temporary restraining order came in a suit filed Wednesday by seven tenants who live in the four projects, but the tenants' lawyer said the order means in effect that the city is required to provide heat and hot water throughout all four projects--a total of 1,482 apartments--because tenants are served by a central heating system in each complex.

The judge ordered Mayor Barry, housing director Robert L. Moore and public housing administrator Sidney Glee to restore heat and hot water to the seven tenants pending a hearing next Friday on the plaintiffs' request for an injunction in the case. The seven are residents of the Arthur Capper housing project, Greenleaf Dwellings, Ellen Wilson Dwellings and Stanton Dwellings.

The four projects are among 52 public housing projects owned and operated by the city and containing nearly 12,000 units. The managers of most projects, including the four involved in the case, are city employes.

Glee said yesterday afternoon that four of the seven plaintiffs now have heat: two at the Arthur Capper project across M Street from the Navy Yard, and two at the Greenleaf Dwellings at 1200 Delaware Ave. SW.

"The lack of adequate heat and hot water in conjunction with the present temperatures constitutes a present and continuing risk to the health of the apartments' occupants," Judge Taylor wrote in her order Thursday.

The tenants and their familes "are suffering and will continue to suffer irreparable injury for which they have no adequate remedy at law unless adequate heat and hot water are provided forthwith," she wrote.

It is highly unusual for tenants to obtain such an order against city officials, according to city officials and lawyers familiar with landlord-tenant cases.

In affidavits filed in the case, the tenants painted a dreary picture of life in the public housing projects, where they pay rents ranging from $24 to $205 a month.

They wrote that they lived without heat and hot water while suffering from frequent flooding, rats and roaches. Repeated calls to management, the affadavits said, produced no response.

One of the tenants, Sandra Edwards of Greenleaf Dwellings, told the court, "I have burned out three stoves," by using them for warmth for herself, her husband and her four children.

She said that while she had been without heat for two years, the project's manager was complaining about the number of stoves she had used.

Grace L. Lancaster, of Stanton Dwellings in Anacostia, said in an affadavit: "We have had no heat at all this winter." She said the management had told her "that these conditions cannot be repaired and that I will have to be relocated."

In addition to being without heat, her apartment often is flooded by water that collects in nearby vacant apartments, she said.

Veleska Sparks and Lillian T. Johnson, both of whom have lived at the Ellen Wilson apartments on Capitol Hill for more than 20 years, said that they have been without heat for the last four years. Mrs. Johnson added that her 4-year-old grandson was suffering from bronchitis. Mrs. Sparks said that her heat recently was restored.

Glee said he found it "hard to believe" that some tenants had lacked heat for four years, because he often had visited Ellen Wilson during Christmas, when there were serious problems with the boilers at the project, and had heard no complaints.