Derivation of Hamilton-Jacobi equation I am trying my own way of deriving the Hamilton Jacobi equation
$$\frac{\partial S}{\partial t} = -H \tag{1}$$ 
through direct variation. I think the difficulty of doing this is that the upper limit of integral:
$S = \int_0^t L dt$
is actually varying. So I try to rewrite the integral in an alternative form:
$S = \int_0^1 L(q(z),\dot{q}(z)) \frac{\partial t}{\partial z} dz$.
Here $z$ parameterize the 'progress' of the motion from the start to the end, which is alway from 0 to 1. Then:
$\delta S = \int_0^1 \{(\frac{\partial L}{\partial q}\delta q+\frac{\partial L}{\partial \dot{q}}\delta \dot{q}) \frac{\partial t}{\partial z}+L\frac{\partial \delta t}{\partial z}\} dz$.
Consider the first two terms first:
$\int_0^1 (\frac{\partial L}{\partial q}\delta q+\frac{\partial L}{\partial \dot{q}}\delta \dot{q}) \frac{\partial t}{\partial z}dz$
By the euler lagrange equation (it holds because we are considering a real trajectory) , also replace time derivative by $\frac{dz}{dt}\frac{d}{dz}$ the first term could be written as:
$=\int_0^1 (\frac{dz}{dt}\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\delta q+\frac{\partial L}{\partial \dot{q}}\frac{dz}{dt}\frac{d}{dz}\delta q) \frac{\partial t}{\partial z}dz$
$=\int_0^1 (\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\delta q+\frac{\partial L}{\partial \dot{q}}\frac{d}{dz}\delta q) dz$
Integrate the second term by parts:
$=\int_0^1 (\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\delta q-\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\delta q) dz=0$
The boundary term vanishes because $\delta q$ vanish at the start and the end (we are only varying the arrival time). Now consider the second part:
$\int_0^1 L\frac{\partial \delta t}{\partial z} dz$.
integration by part again:
$=L \delta t|^{z=1}_{z=0} - \int_0^1 \frac{\partial }{\partial z} L \delta tdz$.
$=L \delta t|^{z=1}_{z=0} - \int_0^1 (\frac{\partial L}{\partial q}\frac{dq}{dz}+\frac{\partial L}{\partial \dot{q}}\frac{d\dot{q}}{dz})\delta t  dz$.
$=L \delta t|^{z=1}_{z=0} - \int_0^1 (\frac{dz}{dt}\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\frac{dq}{dz}+\frac{\partial L}{\partial \dot{q}}\frac{d\dot{q}}{dz})\delta t  dz$.
$=L \delta t|^{z=1}_{z=0} - \int_0^1 (\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\dot{q}+\frac{\partial L}{\partial \dot{q}}\frac{d\dot{q}}{dz})\delta t  dz$.
$=L \delta t|^{z=1}_{z=0} - \int_0^1 (\frac{d}{dz}(\frac{\partial L}{\partial \dot{q}}\dot{q})\delta t  dz$.
$=L \delta t|^{z=1}_{z=0} - (\frac{\partial L}{\partial \dot{q}}\dot{q})\delta t  |_{z=0}^{z=1}+\int_0^1 \frac{\partial L}{\partial \dot{q}}\dot{q}\frac{d}{dz}\delta t  dz$.
The first two terms is just what I need ($-H\delta t|_{z=0}^{z=1}$). However, the last term also shows up, which does not seem to be zero.
Is this approach to derive H-J equation viable?  If not, where did I make the mistake?
 A: The place that I made mistake is here:
$\delta \dot{q} = \delta (\frac{d}{dt}q)$
$= \delta (\frac{dz}{dt}\frac{d}{dz}q)$
Here what I did is to simply took $\frac{dz}{dt}$ outside $\delta$. What need to be done is:
$\delta \dot{q} = \delta (\frac{dz}{dt}\frac{d}{dz}q)$
$= \delta (\frac{dz}{dt})\frac{d}{dz}q+\frac{dz}{dt}\frac{d\delta q}{dz}$
Here I give the correct version of the derivation:
$S = \int_0^1 L(q(z),\dot{q}(z)) \frac{\partial t}{\partial z} dz$.
$\delta S = \int_0^1 \{(\frac{\partial L}{\partial q}\delta q+\frac{\partial L}{\partial \dot{q}}\delta \dot{q}) \frac{\partial t}{\partial z}+L\frac{\partial \delta t}{\partial z}\} dz$.
Consider the first two terms first:
$\int_0^1 (\frac{\partial L}{\partial q}\delta q+\frac{\partial L}{\partial \dot{q}}\delta \dot{q}) \frac{\partial t}{\partial z}dz$
By the euler lagrange equation (it holds because we are considering a real trajectory) , also replace time derivative by $\frac{dz}{dt}\frac{d}{dz}$ the first term could be written as:
$=\int_0^1 (\frac{dz}{dt}\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\delta q+\frac{\partial L}{\partial \dot{q}}\delta (\frac{dz}{dt})\frac{d}{dz}q+\frac{\partial L}{\partial \dot{q}}\frac{dz}{dt}\frac{d\delta q}{dz}) \frac{\partial t}{\partial z}dz$
$=\int_0^1 (\frac{dz}{dt}\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\delta q-\frac{\partial L}{\partial \dot{q}}(\frac{dz}{dt})^2\frac{\partial \delta t}{\partial z}\frac{d}{dz}q+\frac{\partial L}{\partial \dot{q}}\frac{dz}{dt}\frac{d\delta q}{dz}) \frac{\partial t}{\partial z}dz$
$=\int_0^1 (\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\delta q+\frac{\partial L}{\partial \dot{q}}\frac{d}{dz}\delta q-\frac{\partial L}{\partial \dot{q}}\dot{q}\frac{\partial \delta t}{\partial z}) dz$
Integrate the second term by parts:
$=\int_0^1 (\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\delta q-\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\delta q)-\frac{\partial L}{\partial \dot{q}}\dot{q}\frac{\partial \delta t}{\partial z}) dz$
$=-\int_0^1 \frac{\partial L}{\partial \dot{q}}\dot{q}\frac{\partial \delta t}{\partial z} dz$
The boundary term vanishes because $\delta q$ vanish at the start and the end (we are only varying the arrival time). Now consider the second part:
$\int_0^1 L\frac{\partial \delta t}{\partial z} dz$.
integration by part again:
$=L \delta t|^{z=1}_{z=0} - \int_0^1 \frac{\partial }{\partial z} L \delta tdz$.
$=L \delta t|^{z=1}_{z=0} - \int_0^1 (\frac{\partial L}{\partial q}\frac{dq}{dz}+\frac{\partial L}{\partial \dot{q}}\frac{d\dot{q}}{dz})\delta t  dz$.
$=L \delta t|^{z=1}_{z=0} - \int_0^1 (\frac{dz}{dt}\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\frac{dq}{dz}+\frac{\partial L}{\partial \dot{q}}\frac{d\dot{q}}{dz})\delta t  dz$.
$=L \delta t|^{z=1}_{z=0} - \int_0^1 (\frac{d}{dz}\frac{\partial L}{\partial \dot{q}}\dot{q}+\frac{\partial L}{\partial \dot{q}}\frac{d\dot{q}}{dz})\delta t  dz$.
$=L \delta t|^{z=1}_{z=0} - \int_0^1 (\frac{d}{dz}(\frac{\partial L}{\partial \dot{q}}\dot{q})\delta t  dz$.
$=L \delta t|^{z=1}_{z=0} - (\frac{\partial L}{\partial \dot{q}}\dot{q})\delta t  |_{z=0}^{z=1}+\int_0^1 \frac{\partial L}{\partial \dot{q}}\dot{q}\frac{d}{dz}\delta t  dz$.
Add the up first and the second part:
$\delta S = (L  - (\frac{\partial L}{\partial \dot{q}}\dot{q}))\delta t  |_{z=0}^{z=1}$
$\delta S = -H\delta t  |_{z=0}^{z=1}$
The R.H.S only depend on the arrival time difference. Therefore
$\frac{\partial S}{\partial t} = -H$
A: OP's eq. (1) superficially looks like the Hamilton-Jacobi (HJ) equation, but the devil is in the detail. While the HJ equation is a non-linear first-order PDE for Hamilton's principal function, it seems OP is actually talking about a property 
$$\frac{\partial S(q_f,t_f;q_i,t_i)}{\partial t_f}~=~-h_f \tag{12} $$
of the (Dirichlet) on-shell action $S(q_f,t_f;q_i,t_i)$. See eq. (12) in my Phys.SE answer here, where a proof is provided.
See also this related Phys.SE post.
