Jim Varney, the rubberfaced comic who portrayed his rube character ''Ernest'' in hundreds of television commercials and a series of movies, died on Thursday at his home here. He was 50.

The cause was lung cancer, said his lawyer, Hoot Gibson.

Mr. Varney became a cult figure in the 1980's in a series of regional commercials, portraying Ernest P. Worrell, a know-it-all who was fond of asking ''KnowhutImean?'' and who addressed a character known as Vern.

Mr. Varney was also the voice of Slinky Dog in ''Toy Story'' and ''Toy Story 2.''

In the commercials, he got his fingers slammed in a house window, fell off a ladder and got electrically shocked fooling with a broken television set. He promoted dairy products, car dealerships, pizza, radio stations and other products.

''Ernest is a neighbor or relative that we've all had at one time,'' he once said. ''He's abrasive, but he doesn't mean to be. He gets excited and ends up standing on your toes. I try to make him clownish, and I don't want him too low key; and he's physically funny.''