I need to make a part of a program in java that calculates a circle center. It has to be a circle through a given point that touches another circle, and the variable circle center has the possibility to move over a given line.
Here the coordinates of A, B and C and the radius of the circle around A are given. I need to know how to get the coordinates of P and P' when they touch the blue circle around A.


A strong hint, but not a complete solution
Let $$ \newcommand{\bu} {{\mathbf u}} \newcommand{\bv} {{\mathbf v}} \begin{align} s &= \|B - C\|\\ \bu &= \frac{B - C}{s} \end{align} $$ The point $P$ is then $C + t\bu$ for some $t \in \Bbb R$, and I'll follow the picture and consider the case $t < s$ so that we find $P$ instead of $P'$. We'll work out some constraints on $t$.
The first constraint is that the distance from $P$ to $B$ (namely $s - t$), which is the radius of the circle around $P$, must, when added to $r$, the radius of the blue circle, give the distance from $P$ to $A$. Thus:
$$ (s - t) + r = \| A - (C + t \bu) \|. $$ Squaring both sides, and letting $\bv = A - C$ and $e = \|A - C \| = \|\bv\|$, we get \begin{align} (s - t)^2 + 2r(s-t) + r^2 &= \| (A - C) - t \bu) \|^2\\ (s - t)^2 + 2r(s-t) + r^2 &= [ (A - C) - t \bu) ] \cdot [ (A - C) - t \bu) ] \\ s^2 - 2st + t^2 + 2rs-2rt + r^2 &= (A - C)\cdot(A-C) - 2t \bu \cdot (A - C) + t^2 \bu \cdot bu \\ s^2 - 2st + t^2 + 2rs-2rt + r^2 &= (A - C)\cdot(A-C) - 2t \bu \cdot (A - C) + t^2 & \text{, because $\bu$ is a unit vector}\\ s^2 - 2st + t^2 + 2rs-2rt + r^2 &= e^2 - 2t \bu \cdot \bv + t^2 & \text{, defn's of $\bv$ and $e$}\\ s^2 - 2st + 2rs-2rt + r^2 &= e^2 - 2t \bu \cdot \bv & \text{algebra}\\ 2t \bu \cdot \bv - 2st -2rt &= e^2 -s^2 -2rs - r^2& \text{algebra}\\ t( -2 \bu \cdot \bv + 2s + 2r) &= (s+r)^2 - e^2& \text{algebra}\\ t &= \frac{(s+r)^2 - e^2}{-2 \bu \cdot \bv + 2s + 2r }& \text{algebra}\\ \end{align} ...so that gives you the point $P$ (you just compute $P + t\bu$). Now you have to do the same thing, but starting with $(t - s) + r = ...$ to find the point on the other side of $B$.
Here is (not pretty) Matlab code to implement this, and a plot of the result of
being run in the Command window.
The blue circle is the one around point $A$; the red-orange circle is the computed on. The black line segment goes from $C$ to $B$.
Of course, you still have to work through the case where $t > s$ to find the coordinates of the center $P'$ and the radius of the second circle.