I have my Java Program which is running on the windows machine. From this Window machine i need to read a file from the Linux server. I have write this code to authenticate with the Linux Server, and its working fine
session = jsch.getSession("root", "ServerIP", 22);
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword("Passwrod");
session.connect();
System.out.println("Server is connect");
I can see "Server is connect" is printing on my machine that's mean authentication is done with the server. And now there is need to read the file from this server and i have write this code
try
{
File file = new File("/var/log//callrec/core1.log");
LineNumberReader sc = new LineNumberReader(new FileReader(file));
}
catch(Exception e)
{
e.printStackTrace();
}
But its throwing file not found exception. Can any body guide me how can i solve this.
jsch? And, you still are accessing a local file in your code - just creating a session through some mechanism does not mean that theFileclass automatically accesses files on the remote machinehttp://www.jcraft.com/jsch/, but this is only a rough guess ...