-1

I'm getting a Java: 10: error for line 7, when I compile the code listed below. This is sample given to us for this weeks assignment to tailor to meet requirements of the project and I know this same code has popped up repeated on Stack.

import javax.swing.JOptionPane;

public class ProjectTwo
{
   public static void main(String[] args)
   {
      String input;
      input = JOptionPane.showInputDialog("Enter a password.");
      if (!PasswordVerifier.isValid(input))
         JOptionPane.showMessageDialog(null, "Invalid password.");
      else
         JOptionPane.showMessageDialog(null, "Valid password.");
      System.exit(0);
   }
}

Based off the error, I believe I haven't imported the correct utility to use the PasswordVerifier function. I've been digging through:

  • docs.oracle.com

to find possibly what element of javax.swing is applicable to import, with no luck. Any help would be greatly appreciated.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • Is `PasswordVerifier` something that you were supposed to be provided or something you are supposed to write? I do not think it is a standard Java class. – KevinO May 23 '16 at 23:13

1 Answers1

3

There should be an import statement for PasswordVerifier? For example.

import com.package.PasswordVerifier

Example of my output when I ran your code

C:\Users\Aaron\Documents\ProjectTwo.java:9: error: cannot find symbol
  if (!PasswordVerifier.isValid(input))
       ^
symbol:   variable PasswordVerifier
location: class ProjectTwo
1 error
Aaron
  • 175
  • 2
  • 10
  • That's what I figured but wasn't having any luck finding what to function to import for this example to project. Heading back to Oracle for more info. Thank you for the help. – Dayeo78 May 24 '16 at 20:19
  • Write the method yourself. It will be a static boolean method that will return True if input.equals"(password") or return false otherwise – Aaron May 24 '16 at 23:13