You need a backcountry permit from the Forest Service to hike the JMT. You can apply over the internet unfortunately I believe all the July permits have been given out by this method. They usually are reserved the day they become available. The JMT web site has a link to the site you need to get to for a permit. The other way is to show up and get one of the permits that they hold back for walk ins. This gets tricky as you need to line up really early in the morning to get one. There is also a chance that someone will cancel or not show up for a permit that was acquire on line. They become available around 11:00 but you need to sign up the day before. I found that the US Park Service at Yosemite were the most unfriendly and unhelpful bastards on the planet. I was constantly given bad information from them. I got on at Tuolemne Meadows ( that can’t be spelled correctly) and had much better results. It seems to be easier to try for other trail head permits other then out of Yosemite. Good Luck.
Big B