Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
| Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 25th, 2006, 03:27 PM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Main.java:88: 'class' or 'interface' expected

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
  #2 (permalink)  
Old December 13th, 2006, 09:07 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: , , India.
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to gokul_blr Send a message via Yahoo to gokul_blr
Default

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/Se...ndotpclass.htm


Similar Threads
Thread Thread Starter Forum Replies Last Post
interface and abstract class sreenu.pocha C# 2 July 26th, 2006 07:18 AM
Instance of same class in main method ajit Java Basics 1 July 1st, 2006 06:26 PM
Method calls within same class w/Interface gmontanaro C# 0 April 6th, 2006 05:44 PM
denotes a 'field' where a 'class' was expected jdang67 C# 1 November 12th, 2004 03:39 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.