However this late reply, but as Matheiu pointed out I should probably write an answer here to help others.
There was no code change required. It was more of a conceptual thing.
Actually when you share your file with everyone it's actually shared with everyone on your DOMAIN or guest if the guest account is enabled.
You need some way to authenticate when someone is trying to access it. When you access it like this \server-ip\sharedFolder using windows it authenticates itself using your logged-in user and if you are part of the same domain it gives you access.
You need to do the same when you are connecting via JCIFS using linux/mac. You need to give your username and password and if your user is part of that domain you will be authenticated and you can access things that are shared publically or shared with everyone.