Nothing was wrong with Joy Global's (NYSE: JOY) second-quarter numbers -- the company's top and bottom lines actually beat analysts' estimates by some distance. But Mr. Market wasn't happy, and sent its stock down by nearly 10%. Why? Because the company cut back its full-year outlook. But is it time to bring out the yellow flags for Joy?

What's ailing Joy?
The cooling of the Chinese economy is bad news for Joy, as any slowdown in the world's largest coal-consuming nation translates into softer demand for mining equipment. Joy's top line in recent times grew quite a bit because of the boom in commodity consumption and mining in China. Right now, things are looking bleaker, with the economy's manufacturing data weakening by the day. The nation's May Purchasing Managers' Index (an important tool for gauging manufacturing activity) slipped to its lowest level this year. Fears of the economy's second-quarter growth rate falling below the 8% mark are thick in the air.

It's not just China. The coal industry in the U.S. is in a rough state, too. Several coal stocks have lost significant value in recent months. The main culprits? Cheap natural gas and concerns about the global economy. Falling commodity prices and overall fears have even compelled major mining companies to slow their spending plans down. The world's largest mining company, BHP Billiton (NYSE: BHP), feels it's time to "pause" and "take a deep breath" after high commodity prices fueled record growth in the industry. BHP might cut back on its ambitious $80 billion spending target now.

With more than two-thirds of Joy's revenue coming from coal-mining customers, it had to feel the pinch. The company's weak outlook even dragged Caterpillar's (NYSE: CAT) stock along. Understandably so, because Caterpillar is betting big on mining, especially after overtaking Joy as the company with the biggest mining product range.

Not so bad
Things might not seem bright in the near term, but I think long-term investors should get excited especially after Joy's stock price hit its 52-week low post-results. Fool colleague Sean Williams made some very valid points about why coal is here to stay. And not everyone's bearish on the mining sector as a whole.

Take Caterpillar, for instance. It continues to maintain a positive stance on the global mining markets including China, sticking to its forecast of an 8% full-year growth for the nation, and believing it to be a great long-term opportunity. Another great example is that of a megaconglomerate that has just forayed deeper into the mining sector: General Electric (NYSE: GE) is taking over two mining-equipment makers to bet on the high-potential $61 billion global mining industry. Now if a stalwart like GE makes a move, it must have first weighed its pros and cons carefully.

The Foolish bottom line
Joy is expecting China to bottom out soon. Research company Freedonia Group, too, is expecting the sector to recover by next year, and is projecting the world mining equipment market to clock an annual growth of 8.5% through 2015, with the Asia-Pacific region leading the pack.

With long-term optimism intact, the slide in Joy's stock price looks like a good opportunity to me. Its trailing P/E of 8.2 is lower than Cat's trailing P/E of 10.5. A forward P/E of just 6.7 further suggests room for upside in the stock. The company has been balancing its organic and inorganic growth well, and you might do well to add the stock to your watchlist. Click here to add Joy Global.

While Joy waits for a coal recovery, don't let it turn you off from energy investing completely. The Motley Fool has a new free report featuring the only energy stock you'll ever need. Read it today, and Fool on!