Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'class' or 'interface' expected

Status
Not open for further replies.

akiba201

Programmer
Nov 7, 2005
30
CA
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
 
This class is called Main (which can't be a good thing) while you are talking about passwordgenerator class errors.

if you have one curl to many then remove it and resolve the real errors you are getting.

posting your code in code tags will make it more readable.



Christiaan Baes
Belgium

"My new site" - Me
 
If you indent the code, I think you'll find the answer.

Cheers,
Dian
 
Yes, good code indentation is vital in a language like java. If you don't keep your code tidy, the only other way of easily matching parentheses is using an IDE which can highlight them for you. On this site, use the TGML code tags preserve your formatting. As a group, we generally don't have time to waste wading through unformatted code posted here.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top