[proofplan]
We first record that measurability implies inaccessibility, since the measure forbids small cofinal sequences and injections of $\kappa$ into small powersets. It then remains, by the tree-property characterization of weak compactness, to show that every $\kappa$-tree has a cofinal branch. Given a $\kappa$-tree $T$, form the well-founded ultrapower embedding $j:V \to M$ by the measure on $\kappa$; in $M$, the tree $j(T)$ has a level $\kappa$, and any node on that level determines a coherent chain through the original levels of $T$. This chain is a cofinal branch through $T$.
[/proofplan]
[step:Use the measure to prove that $\kappa$ is inaccessible]
Let $U$ be a nonprincipal $\kappa$-complete ultrafilter on $\kappa$. We prove that $\kappa$ is regular and a strong limit cardinal. Let $\operatorname{cf}(\kappa)$ denote the cofinality of $\kappa$, namely the least ordinal type of an unbounded subset of $\kappa$.
First suppose, toward a contradiction, that $\operatorname{cf}(\kappa)=\lambda<\kappa$. Let $c:\lambda \to \kappa$ be a strictly increasing cofinal map. Define an increasing sequence $(\gamma_\xi)_{\xi<\lambda}$ of ordinals below $\kappa$ by
\begin{align*}
\gamma_\xi=\sup\{c(\eta)+1:\eta<\xi\}
\end{align*}
for each $\xi<\lambda$. Since $\lambda=\operatorname{cf}(\kappa)$, every set of ordinals below $\kappa$ of cardinality less than $\lambda$ is bounded in $\kappa$; therefore $\gamma_\xi<\kappa$ for every $\xi<\lambda$. Define a sequence $(A_\xi)_{\xi<\lambda}$ of subsets of $\kappa$ by
\begin{align*}
A_\xi=\{\alpha<\kappa:\gamma_\xi\leq \alpha<\gamma_{\xi+1}\}
\end{align*}
for each $\xi<\lambda$. The sets $A_\xi$ are bounded in $\kappa$, and their union is $\kappa$ because $(\gamma_\xi)_{\xi<\lambda}$ is cofinal in $\kappa$. A bounded subset of $\kappa$ cannot belong to $U$: if $A\subset \beta<\kappa$ and $A\in U$, then by $\kappa$-completeness one of the singletons $\{\alpha\}$ with $\alpha<\beta$ would have to belong to $U$, contradicting nonprincipality. Hence $\kappa\setminus A_\xi\in U$ for every $\xi<\lambda$. Since $\lambda<\kappa$ and $U$ is $\kappa$-complete,
\begin{align*}
\bigcap_{\xi<\lambda}(\kappa\setminus A_\xi)\in U.
\end{align*}
But the sets $A_\xi$ cover $\kappa$, so this intersection is empty, contradicting that an ultrafilter is proper. Thus $\operatorname{cf}(\kappa)=\kappa$.
Now let $\lambda<\kappa$. Suppose, toward a contradiction, that $2^\lambda\geq \kappa$. Choose an injection
\begin{align*}
e:\kappa \to \mathcal{P}(\lambda).
\end{align*}
For each $\xi<\lambda$, define
\begin{align*}
B_\xi=\{\alpha<\kappa:\xi\in e(\alpha)\}.
\end{align*}
Since $U$ is an ultrafilter, exactly one of $B_\xi$ and $\kappa\setminus B_\xi$ belongs to $U$. Define a set $S\subset\lambda$ by declaring $\xi\in S$ if and only if $B_\xi\in U$. For each $\xi<\lambda$, define $C_\xi = B_\xi$ when $\xi\in S$ and define $C_\xi = \kappa\setminus B_\xi$ when $\xi\notin S$.
Then $C_\xi\in U$ for every $\xi<\lambda$, so $\bigcap_{\xi<\lambda}C_\xi\in U$ by $\kappa$-completeness. If $\alpha,\beta$ both lie in this intersection, then for every $\xi<\lambda$ one has $\xi\in e(\alpha)$ if and only if $\xi\in e(\beta)$, so $e(\alpha)=e(\beta)$. Since $e$ is injective, the intersection contains at most one point. This contradicts nonprincipality of $U$, because a member of a nonprincipal $\kappa$-complete ultrafilter cannot be finite. Therefore $2^\lambda<\kappa$ for every $\lambda<\kappa$.
Thus $\kappa$ is regular and a strong limit, so $\kappa$ is inaccessible.
[/step]
[step:Reduce weak compactness to the tree property]
The tree-property characterization of weak compactness states that an inaccessible cardinal is weakly compact if and only if every $\kappa$-tree has a cofinal branch. The previous step proves that $\kappa$ is inaccessible, so it is enough to prove that every $\kappa$-tree has a cofinal branch. Here a $\kappa$-tree is a partially ordered set $(T,<_{T})$ with height $\kappa$, with height map $\operatorname{ht}_{T}:T\to\kappa$ assigning to each node the order type of its set of predecessors, with levels
\begin{align*}
T_\alpha=\{t\in T:\operatorname{ht}_{T}(t)=\alpha\}
\end{align*}
of cardinality $|T_\alpha|<\kappa$ for each $\alpha<\kappa$, and with predecessors of each node well-ordered by $<_{T}$.
Fix an arbitrary $\kappa$-tree $(T,<_{T})$. Replacing $T$ by an isomorphic copy if necessary, assume that every node is an ordinal-coded pair $(\alpha,\xi)$ with $\alpha<\kappa$ and $\xi<\mu_\alpha$ for some cardinal $\mu_\alpha<\kappa$, that $T_\alpha\subseteq\{\alpha\}\times\mu_\alpha$, and that the height map and order relation are coded by subsets of $\kappa$. This replacement is obtained by choosing, for each level $T_\alpha$, an injection of $T_\alpha$ into some ordinal $\mu_\alpha<\kappa$; it does not change whether $T$ has a cofinal branch. It remains to construct a chain meeting every level of $T$.
[guided]
The definition of weak compactness has several equivalent forms. We use the tree-property form: after proving that $\kappa$ is inaccessible, it remains to show that every $\kappa$-tree has a cofinal branch.
Let $(T,<_{T})$ be an arbitrary $\kappa$-tree. Let $\operatorname{ht}_{T}:T\to\kappa$ be its height map, and for each $\alpha<\kappa$ define
\begin{align*}
T_\alpha=\{t\in T:\operatorname{ht}_{T}(t)=\alpha\}.
\end{align*}
By definition of a $\kappa$-tree, $|T_\alpha|<\kappa$ for every $\alpha<\kappa$, and the set of predecessors of each node is well-ordered by $<_{T}$.
We replace $T$ by an isomorphic copy whose nodes are ordinal-coded level by level: each node on level $\alpha$ is a pair $(\alpha,\xi)$ with $\xi<\mu_\alpha$ for some $\mu_\alpha<\kappa$, and the order and height data are coded by subsets of $\kappa$. This does not change whether $T$ has a cofinal branch. The reason this normalization matters is that the ultrapower embedding constructed from the measure has critical point $\kappa$, so it fixes every ordinal below $\kappa$ and therefore fixes each node, each order comparison, and each height assertion involving original levels $T_\alpha$ with $\alpha<\kappa$.
Let $V$ denote the universe of sets, viewed as the domain of the ultrapower construction. Since $U$ is $\kappa$-complete and $\kappa$ is uncountable, $U$ is countably complete; the standard ultrapower theorem for countably complete ultrafilters gives that the ultrapower by $U$ is well-founded. Its Mostowski collapse gives a transitive class $M$ and an elementary embedding
\begin{align*}
j:V\to M.
\end{align*}
The critical point $\operatorname{crit}(j)$ is the least ordinal moved by $j$. Nonprincipality makes $j$ move $\kappa$, while $\kappa$-completeness makes $j$ fix every ordinal below $\kappa$; hence $\operatorname{crit}(j)=\kappa$, so $j(\alpha)=\alpha$ for all $\alpha<\kappa$ and $j(\kappa)>\kappa$.
By elementarity, $j(T)$ is a $j(\kappa)$-tree in $M$ with tree order $<_{j(T)}=j(<_{T})$. Since $\kappa<j(\kappa)$, the level
\begin{align*}
j(T)_\kappa=\{x\in j(T):\operatorname{ht}_{j(T)}(x)=\kappa\}
\end{align*}
is nonempty in $M$. Choose $x\in j(T)_\kappa$.
For each $\alpha<\kappa$, the predecessor set of $x$ in $j(T)$ is well-ordered by $<_{j(T)}$ with order type $\kappa$, so there is a unique node $b_\alpha\in j(T)_\alpha$ such that $b_\alpha<_{j(T)}x$. Because $j$ fixes every ordinal and every coded node on levels below $\kappa$, the $\alpha$th level of $j(T)$ is exactly the original level $T_\alpha$ for each $\alpha<\kappa$. Thus $b_\alpha\in T_\alpha$.
Define
\begin{align*}
B=\{b_\alpha:\alpha<\kappa\}.
\end{align*}
This set meets every level of $T$. If $\alpha<\beta<\kappa$, then $b_\alpha$ and $b_\beta$ are both predecessors of $x$ in $j(T)$, and the predecessor set of a node is linearly ordered by the tree order. Since their heights are $\alpha$ and $\beta$, respectively, we have $b_\alpha<_{j(T)}b_\beta$. On levels below $\kappa$, $<_{j(T)}$ agrees with $<_{T}$, so $b_\alpha<_{T}b_\beta$. Therefore $B$ is a chain meeting every level of $T$, hence a cofinal branch through $T$.
Since $T$ was arbitrary, every $\kappa$-tree has a cofinal branch. Together with inaccessibility, the tree-property characterization gives that $\kappa$ is weakly compact.
[/guided]
[/step]
[step:Form the ultrapower embedding with critical point $\kappa$]
Let $V$ denote the universe of sets, viewed as the domain of the ultrapower construction. Use the standard ultrapower theorem for measurable cardinals: because $U$ is $\kappa$-complete and $\kappa$ is uncountable, $U$ is countably complete, so the ultrapower by $U$ is well-founded. Its Mostowski collapse is a transitive class $M$, together with an elementary embedding
\begin{align*}
j:V \to M.
\end{align*}
The critical point $\operatorname{crit}(j)$ denotes the least ordinal $\alpha$ such that $j(\alpha)\neq\alpha$, when such an ordinal exists. We verify that $\operatorname{crit}(j)=\kappa$. If $\alpha<\kappa$ and $f:\kappa\to\alpha$ is any function, then the partition $(f^{-1}(\{\beta\}))_{\beta<\alpha}$ has fewer than $\kappa$ many pieces. Since $U$ is an ultrafilter and is $\kappa$-complete, exactly one fiber $f^{-1}(\{\beta\})$ belongs to $U$; hence every element of the ultrapower representing an ordinal below $\kappa$ is represented by a constant function. Therefore $j(\alpha)=\alpha$ for every ordinal $\alpha<\kappa$. On the other hand, the class of the identity map $\operatorname{id}_\kappa:\kappa\to\kappa$ is an ordinal below $j(\kappa)$ in the ultrapower and is greater than every constant class $j(\alpha)$ with $\alpha<\kappa$, because $\{\xi<\kappa:\alpha<\xi\}\in U$ by nonprincipality and the bounded-set argument above. Thus $j(\kappa)>\kappa$, and consequently $\operatorname{crit}(j)=\kappa$.
We will use the elementary embedding only on the structure consisting of the tree $T$, its order $<_{T}$, its level function, and the assertion that $T$ has height $\kappa$ with all levels of size $<\kappa$. By elementarity, $j(T)$ is a $j(\kappa)$-tree in $M$, with tree order $<_{j(T)}=j(<_{T})$.
[/step]
[step:Choose a node at level $\kappa$ of $j(T)$]
Since $M$ satisfies that $j(T)$ has height $j(\kappa)$ and since $\kappa<j(\kappa)$, the level
\begin{align*}
j(T)_\kappa=\{x\in j(T):\operatorname{ht}_{j(T)}(x)=\kappa\}
\end{align*}
is nonempty in $M$. Choose a node $x\in j(T)_\kappa$.
For each $\alpha<\kappa$, the predecessors of $x$ in $j(T)$ are well-ordered by $<_{j(T)}$ with order type $\kappa$. Therefore there is a unique node $b_\alpha\in j(T)_\alpha$ such that
\begin{align*}
b_\alpha <_{j(T)} x.
\end{align*}
Because each node on level $\alpha<\kappa$ is coded as a pair $(\alpha,\xi)$ with $\xi<\mu_\alpha<\kappa$, the embedding $j$ fixes that code and fixes the bound $\mu_\alpha$. By elementarity applied to the coded height relation, a node has $j(T)$-height $\alpha$ if and only if its same code has $T$-height $\alpha$. By elementarity applied to the coded order relation, two such nodes are ordered by $<_{j(T)}$ if and only if they are ordered by $<_{T}$. Hence no new coded node appears on a level $\alpha<\kappa$ of $j(T)$, the restriction of $j(T)$ to levels below $\kappa$ is exactly the original restriction of $T$ to levels below $\kappa$, and $j(T)_\alpha=T_\alpha$ for each $\alpha<\kappa$. Hence $b_\alpha\in T_\alpha$ for every $\alpha<\kappa$.
[/step]
[step:Pull the predecessors of $x$ back to a branch through $T$]
Define
\begin{align*}
B=\{b_\alpha:\alpha<\kappa\}.
\end{align*}
We claim that $B$ is a cofinal branch through $T$.
First, $B$ meets every level of $T$: for each $\alpha<\kappa$, the element $b_\alpha$ belongs to $T_\alpha$. Second, $B$ is linearly ordered by $<_{T}$. Indeed, if $\alpha<\beta<\kappa$, then both $b_\alpha$ and $b_\beta$ are predecessors of $x$ in the tree $j(T)$, and the predecessor set of a node in a tree is well-ordered by the tree order. Since $b_\alpha$ has height $\alpha$ and $b_\beta$ has height $\beta$, the only possible order relation is
\begin{align*}
b_\alpha <_{j(T)} b_\beta.
\end{align*}
On levels below $\kappa$, the order $<_{j(T)}$ agrees with the original order $<_{T}$, so
\begin{align*}
b_\alpha <_{T} b_\beta.
\end{align*}
Thus $B$ is a chain in $T$ meeting every level below $\kappa$, hence a cofinal branch through $T$.
Because $T$ was arbitrary, every $\kappa$-tree has a cofinal branch. Together with inaccessibility, the tree-property characterization of weak compactness implies that $\kappa$ is weakly compact.
[/step]