Distance between point (P) and tri is easy...
Take the face normal of the tri ( verts v1,v2,v3):
myVector n = (v2-v1).crossProduct( v3 - v1 );
Then just take tha absolute dot product this with the vector from any tri point to the point in question:
float dist = fabs( n.dotProduct( P - v1 ) );
Distance from a line to a tri is much more complicated, I would google for effecient algorithms for it.
Correction - On second thoughts, this won't do at all
This just gives the distance from a plane. Sry... Ill look up the distance from a tri instead...
Ok... Its really not nice.
Heres a link to the theory:http://www-compsci.swan.ac.uk/~csmark/PDFS/dist.pdf
Heres a link to some source that does it (not java):http://xengine.sourceforge.net/docs/structXEngine_1_1Math_1_1DistanceAlgorithms_1_1DistancePointToTriangle.html
Hope this helps