Hi, I am trying to use the Apache email validator code. I tried to use two import statements to import the apache email validator for testingemail addresses but they are not working:
import org.apache.commons.validator.routines.EmailValidator; https://stackoverflow.com/questions/624581/what-is-the-best-java-email-address-validation-method and importorg.apache.commons.validator.routines.InetAddressValidator; https://github.com/apache/commons-validator/blob/master/src/main/java/org/apache/commons/validator/EmailValidator.java packagecom.mycompany.validatename; //importorg.apache.commons.validator.*; ERROR, How to correct? //importorg.apache.commons.validator.routines.InetAddressValidator; ERROR,how to coorect? importjava.util.regex.Matcher; importjava.util.regex.Pattern; importjavax.swing.JOptionPane; public classValidateNameForm extends javax.swing.JFrame { publicValidateNameForm() { initComponents(); } private voidjTF1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO addyour handling code here: } private voidCheckIfInputValid(String input, String regex){ String s; Patternpattern = Pattern.compile(regex); s =input.trim(); Matchermatcher = pattern.matcher(s); JOptionPane.showMessageDialog(null, "Input "+s+" isvalid " + String.valueOf(matcher.matches())); } private voidjButton1ActionPerformed(java.awt.event.ActionEvent evt) { StringemailAddress= jTF1.getText(); booleanisValidEmail =EmailValidator.getInstance().isValid(emailAddress);//SYNTAX ERROR } public staticvoid main(String args[]) { try { for(javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch(ClassNotFoundException ex) { : : } // Variablesdeclaration - do not modify privatejavax.swing.JButton jButton1; privatejavax.swing.JLabel jLabel1; privatejavax.swing.JTextField jTF1; // End ofvariables declaration } Please guide me whatis the correct import statement for email validator ? I have show twowrong import statements, please tell me the correct ones. What is the correctsyntax of : boolean isValidEmail= EmailValidator.getInstance().isValid(emailAddress); Somebody, pleaseguide me. Zulfi.