Subject: Main.java:88: 'class' or 'interface' expected
Posted By: samnachilomo Post Date: 11/25/2006 2:27:56 PM
Hi,

I need help with the error message above. It looks like I have an extra curl bracket (which is true) but when I remove it I get even more errors as my PasswordGenerator class is not recognized when I remove this curl brack. Could someone out there help?

The code is shown bellow.


package SkeyClass;
import java.util.StringTokenizer;
import java.awt.*;
import java.util.*;
import java.io.*;
import java.lang.*;


public class Main{
    
    /** Creates a new instance of Main */
    public Main() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String argv[]) {
        String seed, passphrase;
    int seq;
    PasswordGenerator otpwd;
    int hashalg;
    String hashtype;

    if ((argv.length < 3) || (argv.length > 4)) {
        System.err.println("usage: jotp sequence seed passphrase" +
                   "[md4|md5]");
        return;
    }
    seq = new Integer(argv[0]).intValue();
    seed = new String(argv[1]);
    passphrase = new String(argv[2]);
    
        if (argv[3].equals("5") || argv[3].equals("md5") ||
        argv[3].equals("MD5")) {
        hashtype = "md5";
        hashalg = PasswordGenerator.MD5;
    }
        
        otpwd = new PasswordGenerator(seq, seed, passphrase);
    System.out.println("Using " + hashtype + ". Thinking...");
    otpwd.calc();
    System.out.println(otpwd);
    }

     public boolean action(Event evt, Object arg) {
    String tmpstr, tmpstr2, seed, passphrase;
    int seq, hashalg;
    PasswordGenerator otpwd;

        /* Split up challenge */
        tmpstr = chaltf.getText(); //please enter paraphrase
        StringTokenizer st = new StringTokenizer(tmpstr);
        if (st.countTokens() != 2) {
        otptf.setText("bogus challenge"); //printout this message
        return true;
        }
        tmpstr2 = st.nextToken();
        try {
        seq = (Integer.parseInt(tmpstr2));
        } catch (NumberFormatException e) {
        otptf.setText("bogus sequence number '" + tmpstr2 + "'");
        return true;
        }
        seed = st.nextToken();
        passphrase = pwtf.getText();
        otptf.setText("Okay, thinking...");
        otpwd = new PasswordGenerator(seq, seed, passphrase);
        otpwd.calc();
        otptf.setText(otpwd.toString());
            
            return true;
     }   
}
}


Main.java:88: 'class' or 'interface' expected

Main.java:88: 'class' or 'interface' expected




Reply By: gokul_blr Reply Date: 12/13/2006 8:07:08 AM
1. Try to avoid creating the class name with Main or something with keyword even with other upper/lower cases.

refer to this example may be useful

http://www.java2s.com/ExampleCode/Security/Applettoserveasanskeycalculatorapplicationwrapperaroundotpclass.htm

Go to topic 53573

Return to index page 95
Return to index page 94
Return to index page 93
Return to index page 92
Return to index page 91
Return to index page 90
Return to index page 89
Return to index page 88
Return to index page 87
Return to index page 86