Hi jacob,
Thanks for your reply. I have now understood that it's not possible to join 2 anchor points by preserving their handles in Illustrator.
Anyways, I have tried writing a script that achieves this arbitrarily.
function joinTwoAnchorPoints(anchor1, anchor2) {
// Create a new path item
var line = activeDocument.pathItems.add();
// Create an array to hold the points for the new line
var lpp = Array();
// Push the two anchor points into the array
lpp.push(anchor1.anchor);
lpp.push(anchor2.anchor);
// Set the entire path of the new line with the points
line.setEntirePath(lpp);
// Set the handles of the segment endpoints
for (var i = 0; i < line.pathPoints.length; i++) {
line.pathPoints[i].leftDirection = i == 0 ? anchor1.rightDirection : anchor2.rightDirection;
line.pathPoints[i].rightDirection = i == 0 ? anchor1.leftDirection : anchor2.leftDirection;
}
// Redraw the artwork
app.redraw();
}
var selectedPathItem1 = selection[0],
selectedPathItem2 = selection[1];
if (selection.length == 2 && selectedPathItem1.typename === "PathItem" && selectedPathItem2.typename === "PathItem") {
var points1 = selectedPathItem1.pathPoints,
points2 = selectedPathItem2.pathPoints;
// Get anchor points
for (var i = 0; i < points1.length; i++)
if(points1[i].selected === PathPointSelection.ANCHORPOINT) var anchor1 = points1[i];
for (var i = 0; i < points2.length; i++)
if(points2[i].selected === PathPointSelection.ANCHORPOINT) var anchor2 = points2[i];
if (anchor1 && anchor2) {
joinTwoAnchorPoints(anchor1, anchor2);
// Remove the orignal points
points1.length === 1 && selectedPathItem1.remove();
points2.length === 1 && selectedPathItem2.remove();
}
else alert("Please select two anchor points");
}
else alert("Please select two anchor points");
This works for joining 2 anchor points (Sometimes also for more anchor points, as I'm unable to cover all the cases). This creates a new line segment of 2 endpoints that are placed in the positions of the original anchor points and adjusts the handles of the endpoints to match the handles of the original anchor points.

For joining 2 endpoints of 2 different paths:

While this doesn't join the 2 points, it only places the curved segment over the selected two points and doesn't remove them. This requires each of the points to be joined (Ctrl + J) manually to obtain a continuos path.
However, this sort of solves the original issue. Wish adobe implements such features, that reduces manual work upto some extent.