John A. Shorter, a prominent District defense attorney who maintains he is not guilty of income tax evasion because he is a "compulsive gambler," cannot present expert witnesses to support that argument, a federal judge ruled here yesterday.

U.S. District Court Judge Harold H. Greene said that even though "pathological gambling" is widely regarded as a mental disorder there is "no general acceptance" among experts that gamblers are forced by their habit not to pay taxes.

At a pretrial hearing this week, two psychologists testifying for Shorter made that contention, while three psychiatrists and a psychologist called by the government strongly disputed it.

If Shorter's experts are correct, Greene declared in a 16-page opinion, "it would be difficult, if not impossible, to establish a principle dividing line between a lawyer who evades his income taxes on account of his compulsive gambling, and an individual who craves alcohol or drugs and commits robberies . . . to obtain the funds to satisfy his needs."

In both cases, Greene continued, "there could be presumed to be compelling forces which cause the individual" to commit a crime, and, under the argument made by Shorter, both would be "exonerated."

"That is not, and cannot be, the law," Green said.

A grand jury indictment last November charged Shorter, 57, with seven counts of tax evasion and failing to pay $287,600 in taxes, penalties, and interest from 1972 through 1983.

In yesterday's opinion, Greene said that although Shorter cannot call on experts to establish a link between gambling and tax evasion, he may testify himself about how "his gambling propensities related to his inability to pay his taxes when they were due."

In June Shorter was scheduled to plead guilty to six misdemeanor counts in the case in return for an agreement by prosecutors to dismss the more serious felony charge. But he withdrew from the plea bargain just minutes before it was to be presented in court.

During this week's hearing, his new attorney, Spencer H. Boyer, said Shorter was compelled by his mental disorder to spend nearly all his money on gambling, rather than pay taxes. Boyer said gambling also explained Shorter's "cash lifestyle" in which he accepted all fees in cash and kept no bank accounts.

Assistant U.S. Attorney Carol E. Bruce said the government's evidence shows that during the years Shorter did not pay taxes he spent substantial sums on renting a Mercedes and on expensive gifts to a girlfriend. The government contends that Shorter did his business in cash to avoid making the records through which taxes are computed.

His trial is scheduled to begin on Tuesday.