It entirely depends upon the book. Some were met with the same accolades that they are given today, while others went largely unnoticed during the author's lifetime, and only achieved fame in later years. Of course other books are regarded as masterpieces when they are first written, but fail the test of time and are forgotten.
You might find the reception of Moby-Dick to be an interesting example. Herman Melville was considered to be quite a successful author in his lifetime, until the release of what he thought would be his magnum opus, Moby-Dick. Instead of catapulting him into greater fame (as he expected), the publication of the book resulted in his gradual decline into obscurity. It wasn't until years after his death that the book was "rediscovered" and hailed as the literary classic that it is regarded as today.
Yes, it depends deeply on the particular work, the country of reception, and also the type of "literary classic" we are referring to.
Novels were not always considered to be the high art form that they are today. Depending upon who you ask, the novel is a relatively recent innovation. The English novelistic tradition begins in the late 17th and early 18th century. Oroonoko, Pamela, and Robinson Crusoe are some major examples. In many cases (Oroonoko is a notable one), early novels were somewhat disjointed amalgamations of romances, travelogues, and epic poems. Later critic Mikhail Bakhtin called the novel "a creature from an alien species." That said, novels became very “popular” which is not necessarily to say that they received axiological acclaim or were considered to be high art. Novels were seen as being low and somewhat smutty. In England, novels were widely read by all, but novel reading was associated femininity and with a partiality toward the trivial. Its all but a literary tradition for novel writers of that era to apologize to the reader in prefatory material for writing “a novel” in the first place. Its no coincidence that this was the period in which writing became an economically viable occupation and novel writing in particular was often compared to an act of “whoring” (especially, as you could imagine, in the case of female authors). In Jane Austen’s Northanger Abbey (a novel which is in many ways about the status of novel’s as a literary genre) a character is asked if he reads novels and tellingly remarks that “gentlemen read better books.”
The reception of Pamela, or Virtue Rewarded and its progeny of contemporary parodies (Anti-Pamela, Shamela) is a great example of the popular reception of novels in the 18th century. Pamela’s popularity wasn’t truly “critical” but rather populist and providential. At the height of its popularity, Pamela even spawned some odd merchandising including “branded” (an anachronism) fans and playing cards. Though, the general assertion of the various Pamela parodies was that Pamela contains a vast amount of veiled eroticism and became popular by arousing its readers rather than by intellectually or morally engaging them.
The stigma against novels as a high literary form was dissolved to some degree after the career of Jane Austen and at the dawn of the 19th century. That is a period of time that I am admittedly a little less informed about. However, it can certainly be asserted that all this baggage of being a “smutty” and populist genre remains with the novel to some extent even today.
For further reading along these lines I’d recommend Ian Watt’s “The Rise of the Novel”
In the later part of the 19th century, the works of Charles Dickens were arguably more popular than they are today. The wide popularity and also triviality of novels and fiction in the 19th century was spurred on by their form of publication. Rather than being published all at once, novels would often be serialized in literary magazines chapter by chapter or part by part. This introduced an element of suspense comparable to what TV dramas produce today. Chapters and parts would often end in cliffhangers that would help sell the following issue. I cannot seem find the source for it now so it could be just legend, but I have read or been told of a particular instance in which Dickens left the fate of a beloved character in the balance at the end of a chapter and public anxiety was so high that people in America crowded around the harbor as the ship carrying the next issue came in from England. A crew member of the ship, understanding the reason for the crowd yelled the news of the character’s death before the ship docked to much misery and grieving. The current reception of TV shows like Game of Thrones is actually a fairly meaningful way of thinking about how some novels were received during this period. They were extremely popular, experienced with visceral emotion, and while generally thought to be of quality; they wouldn’t necessarily be found in an art museum.
It might also be useful to note that literary criticism in the 19th century was overwhelmingly didactic. That is to say that a work of literature was often praised or disregarded based on its perceivable moral value. This is one of the reasons that, as mentioned in a previous comment, Moby-Dick wasn’t hailed as a masterpiece at the time of its publication. Its interesting that you mentioned The Picture of Dorian Gray specifically because much of Wilde’s writing (The Critic as Artist, numerous letters, and the preface to the 1891 edition of The Picture of Dorian Gray) directly asserts his view that works of art should not be judged based on their subjective “moral value”. In the preface to Dorian Gray, Wilde famously remarks: “There is no such thing as a moral or an immoral book. Books are well written, or badly written. That is all.”
Despite Wilde’s defiance, this didactic criticism had a profound effect on the textual history of The Picture of Dorian Gray. This textual history is well outlined by Nicholas Frankel in the introductions to the recent “uncensored” edition published by the Harvard University Press (which, by the way, is a fantastically well annotated edition that I’d highly recommend to anyone interested in the novel). Wilde had his original manuscript typed up and sent off to Lippincott's Monthly Magazine where it was to be serialized. However, Wilde’s manuscript presented something of a fiasco for Lippincott’s editors. Frankel estimates that three different hands made revisions to the text. Many of these revisions were overarching censorships of material deemed too erotic or especially material deemed too homoerotic. Wilde was never given any pass at these revisions and never saw them before the text was published. Its easily to scoff of these editing choices, but it one should notee that the magazine might have faced legal action or at the very least economic rejection if it published material that was morally scandalous. Even Lippincott’s censored text received scathing reviews as an evil and morally abject novel. Wilde responded directly to many of these reviews arguing the value of the novel in numerous letters to no real avail. In 1891 Wilde revised and expanded the novel, but Frankel argues that he never regained access to his original typed manuscript and given the scathing he had received in reviews opted to expand on the censored and published edition with an even more censored edition. The self-censorship between the 1890 and the 1891 editions was later used as evidence against Wilde in his famous trial. The “uncensored” Harvard University Press edition is a corrected printing of Wilde’s original manuscript before the Lippincott publishers made their revisions. This Harvard edition is the first widely printed circulation of the uncensored text and perhaps it attests to the power of contemporary reception that this edition was first published as recently as 2011.
Hopefully that is a fairly interesting and detailed look into some of the ways texts have been received, though I’ll admit that its certainly not exhaustive. Its worth it to note, for example, that novels like The Picture of Dorian Gray would have been received with much more admiration and without moral rejection in France where the concept of “yellow” books like “À rebours” had already become popular.
It all depends on specific people.
Dostoyevsky was recognized by the Russian society, including the Emperor, as a great writer. He had great sales. Brothers Karamazov was his last book so by that time everyone knew him. He was compared to greatest Russian poet/writer, Pushkin, and most people would not be surprised we still read Dostoevsky. Other famous Russian writers were recognized in their lifetime too, like Tolstoy or Bulgakov (though the latter suffered from political problems).
On the other hand you have examples of more modern authors like Franz Kafka who wasn't even translated to English for many years after his death. On a similar note, Lovecraft wasn't really known in his time even though he has an enormous influence on modern fantasy, sci-fi and horror genres. So there's no clear answer.