Reputation: 27
Alright so when I try to compile this in java, I get the following error message
error: Class names, 'TokenTest', are only accepted if annotation processing is explicitly requested 1 error
What does this mean and how can I fix it? I've tried numerous things but cant understand what it is referring to. Thanks for your help! Does this mean I need to change the name so it isn't TokenTest?
import java.io.*;
import java.util.*;
class TokenTest {
public static void main (String[] args) {
TokenTest tt = new TokenTest();
tt.dbTest();
}
void dbTest() {
DataInputStream dis = null;
String dbRecord = null;
try {
File f = new File("sales.info");
FileInputStream fis = new FileInputStream(f);
BufferedInputStream bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
// read the first record of the database
while ( (dbRecord = dis.readLine()) != null) {
StringTokenizer st = new StringTokenizer(dbRecord, ",");
String fname = st.nextToken();
String lname = st.nextToken();
String city = st.nextToken();
String state = st.nextToken();
System.out.println("First Name: " + fname);
System.out.println("Last Name: " + lname);
System.out.println("City: " + city);
System.out.println("State: " + state + "\n");
}
} catch (IOException e) {
// catch io errors from FileInputStream or readLine()
System.out.println("Uh oh, got an IOException error!" + e.getMessage());
} finally {
// if the file opened okay, make sure we close it
if (dis != null) {
try {
dis.close();
} catch (IOException ioe) {
}
}// end if
}// end finally
} // end dbTest
} // end class
Upvotes: 0
Views: 116
Reputation: 72844
From this link about common problems when compiling Java:
Class names, 'HelloWorldApp', are only accepted if annotation processing is explicitly requested
If you receive this error, you forgot to include the
.java
suffix when compiling the program. Remember, the command isjavac HelloWorldApp.java
notjavac HelloWorldApp
.
After fixing the error, you would get a warning about the use of a deprecated method in the following line:
while ((dbRecord = dis.readLine()) != null) {
This is because DataInputStream#readLine
is deprecated. See the class Javadoc page to know why it is deprecated and which API to use instead.
Upvotes: 3
Reputation: 390
If you receive this error, you forgot to include the .java suffix when compiling the program.
Upvotes: 3