code: public static Point projectPoint(Geometry point, Geometry geometry) {
          if (point == null || geometry==null) {
              return null;
          }
          if (point.getDimension()==0 && geometry.getDimension() == 1) {
              LengthIndexedLine ll = new LengthIndexedLine(geometry);
              double index = ll.project(point.getCoordinate());
              return geometry.getFactory().createPoint(ll.extractPoint(index));
          } else {
              return null;
          }
      }
docs: Project a point on a linestring or multilinestring
  @param point
  @param geometry
  @return