title: Java ssh connection in Windows and Linux
body: <p>I'm trying to connect to SSH with a Java application, but I'm not having much success because it gives an unexpected error. My application is running on a Windows computer but I am trying to connect to a Fedora 29 linux server. Import information merely changed. And by the way, I do not just need the connection, but also that this code executes commands on that terminal.</p>
  
  <p>I already got the connection but it gives an error on line 22 .</p>
  
  <pre><code>"package teste;
  
  import com.jcraft.jsch.*; 
  import java.io.InputStream; 
  import java.io.InputStreamReader; 
  import java.util.Scanner;
  
  public class SSHReadFile { public static void main(String args[]) { String user = "root";
   String password = "xxxxxxx"; 
   String host = "000.000.000.000"; 
   int port = 22; 
   String remoteFile = "/home";
   try { JSch jsch = new JSch();
      com.jcraft.jsch.Session session = jsch.getSession(user, host, port);
   session.setPassword(password); 
   session.setConfig("StrictHostKeyChecking", "no"); 
   System.out.println("Establishing Connection..."); 
   session.connect(); System.out.println("Connection established.");
   System.out.println("Crating SFTP Channel."); 
   Channel sftpChannel = session.openChannel("sftp"); 
   sftpChannel.connect(); 
   System.out.println("SFTP Channel created."); 
   InputStream inputStream = sftpChannel.get("/home"); 
   try (Scanner scanner = new Scanner(new InputStreamReader(inputStream))) { while (scanner.hasNextLine()) { String line = scanner.nextLine(); 
   System.out.println(line); } } } catch (JSchException e) { } 
   } 
  
      public class Session {
  
          public Session() {
          }
  
          public void setConfig(String strictHostKeyChecking, String no) {
              throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
          }
  
          public void setPassword(String password) {
              throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
          }
      }
  
      public class ChannelSftp {
  
          public ChannelSftp() {
          }
  
          public void connect() {
              throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
          }
  
          public InputStream get(String remoteFile) {
              throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
          }
      }
   }"   
  </code></pre>
  
  <p>Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: com.jcraft.jsch.Channel.get
      at teste_ls.SSHReadFile.main(SSHReadFile.java:22)</p>