Calculus of variations, minimizing $\int_0^\pi y' ^2 - ky^2 dx$. Please check my work. I have to minimize the functional 
$$J[y] =\int_0^\pi y' ^2 - ky^2 dx$$
subject to $y(0)=y(\pi)=0$. The parameter $k$ is positive. Writing down the Euler-Lagrange equation, I have:
$$y'' +ky =0,$$
which implies $y=A\cos\sqrt{k}x + B\sin\sqrt{k}x $. However, imposing the boundary conditions gives first of all $A=0$, and then $B$ arbitrary, given that $\sqrt{k} \in \mathbb{Z}$, otherwise no solution. Thus $k=m^2$ for $m \in \mathbb{N}$.
Ultimately, the solutions are
$$y_m = B\sin mx$$
Since I want to find the minimal value of the functional, I substitute into the integral:
$$J[y_m]=\int_0^\pi B^2 m^2 \cos (2mx) \ dx = 0.$$
Is this solution correct?

If your method were correct, the minimum would be achieved by the solution corresponding to $B=0$, and the minimum would be equal to $0$.
But, for $y=B\sin x$, we get $J[y]=\frac{\pi}{2}B^2(1-k)$, which for $k>1$, $$\lim_{B\to\infty}J[y]=-\infty.$$
Hence, in order to have a minimum either $k$ should be $\le 1$, or something else is missing from the formulation.
