Welcome to JavaRanch.
i am unable to replace when hostnames are under .jar.
Does that mean you want to alter the contents of jar files? An approach like this will only work for text files - you would need to extract the jar file (and any other archive and compression formats like tar, zip gzip etc.), run the script recursively over the contents, and then jar (tar, zip, gzip, etc.) the file back together.