title: Command prompt "access denied" error for a simple java program
body: <p>I created the source file .java with the following code:</p>
  
  <pre><code>// bank.java
  // demonstrates basic OOP syntax
  // to run this program: C&gt;java BankApp
  ////////////////////////////////////////////////////////////////
  class BankAccount
  {
  private double balance;                   // account balance
  public BankAccount(double openingBalance) // constructor
  {
  balance = openingBalance;
  }
  public void deposit(double amount)        // makes deposit
  {
  balance = balance + amount;
  }
  public void withdraw(double amount)       // makes withdrawal
  {
  balance = balance - amount;
  }
  public void display()                     // displays balance
  {
  System.out.println(“balance=” + balance);
  }
  }  // end class BankAccount
  ////////////////////////////////////////////////////////////////
  
  class BankApp
  {
  public static void main(String[] args)
  {
  BankAccount ba1 = new BankAccount(100.00); // create acct
  System.out.print(“Before transactions, “);
  ba1.display();                         // display balance
  ba1.deposit(74.35);                    // make deposit
  ba1.withdraw(20.00);                   // make withdrawal
  System.out.print(“After transactions, “);
  ba1.display();                         // display balance
  }  // end main()
  }  // end class BankApp
  </code></pre>
  
  <p>I compiled it using the command "javac" and got two class files - each one for one class.
  I try to run it with cmd, but I get the error "access denied" after I type in: </p>
  
  <pre><code>C:\new&gt;java -cp &lt;C:\new&gt; BankApp.class
  </code></pre>
  
  <p>After typing in:</p>
  
  <pre><code>C:\new&gt;java BankApp.class
  </code></pre>
  
  <p>I get: Error: Could not find or load main class BankApp.class</p>