title: replacing hard coded credentials
body: <p>I built a simple java app. However, I can't understand how could I secure this app to avoid hard-coded passwords that a decompiler won't be able to reveal.</p>
  
  <p><strong>LoginMain</strong></p>
  
  <pre><code>import java.util.Scanner;
  
  public class LoginMain {
  
      public static void main(String[] args) {
          String Username;
          String Password;
          Password = "admin";
          Username = "admin";
          Scanner input1 = new Scanner(System.in);
          System.out.println("Enter Username : ");
          String username = input1.next();
          Scanner input2 = new Scanner(System.in);
          System.out.println("Enter Password : ");
  
          String password = input2.next();
          if (username.equals(Username) &amp;&amp; password.equals(Password)) {
              System.out.println("Access Granted! Welcome!");
          } else if (username.equals(Username)) {
              System.out.println("Invalid Password!");
          } else if (password.equals(Password)) {
              System.out.println("Invalid Username!");
          } else {
              System.out.println("Invalid Username &amp; Password!");
          }
      }
  }
  </code></pre>
  
  <p><strong>LoginNew.java</strong></p>
  
  <pre><code>import java.util.Scanner; 
  
  public class LoginNew {
      public static void main(String[] args) {
          String Username;
          String Password;
          Scanner scan = new Scanner (new File("1.txt"));
          Scanner input1 = new Scanner(System.in);
          System.out.println("Enter Username : ");
          String username = input1.next();
          Scanner input2 = new Scanner(System.in);
          System.out.println("Enter Password : ");
          String password = input2.next();
  
          if (username.equals(Username) &amp;&amp; password.equals(Password)) {
              System.out.println("Access Granted! Welcome!");
          } else if (username.equals(Username)) {
              System.out.println("Invalid Password!");
          } else if (password.equals(Password)) {
              System.out.println("Invalid Username!");
          } else {
              System.out.println("Invalid Username &amp; Password!");
          }
      }
  }
  </code></pre>
  
  <p>However, the system presents me :</p>
  
  <pre><code>loginNew.java:9: error: cannot find symbol
          Scanner scan = new Scanner (new File("1.txt"));
                                          ^
    symbol:   class File
    location: class loginNew
  1 error
  Error: Could not find or load main class loginNew  
  </code></pre>
  
  <p>I created the file 1.txt with my credentials:  Password = "admin";
  Username = "admin";  Simple stuff but Im lost. sorry..</p>