본문 바로가기
개발/기타

Java에서 syntax error on token identifier expected after this token 대처 방법

by belitino 2014. 9. 10.

출처:

http://stackoverflow.com/questions/21343068/syntax-error-on-token-identifier-expected-after-this-token

http://stackoverflow.com/questions/21990742/getting-error-in-eclipse-syntax-error-on-token-start-identifier-expected

 

간단한 java 프로그램인데 Eclipse에서 갑자기 Syntax error on token "XXXXX", identifier expected after this token 에러 메시지가 나오면서 컴파일이 되지 않는 경우가 발생했는데 구글링을 해보니 다음과 같은 경우에 발생하는 오류였습니다.

 

1. 키워드 누락

   첫번채 출처에서처럼 필요한 키워드를 누락하는 경우에 발생. 누락된 키워드를 집어넣은면 문제 해결.

 

2. main() 누락

   main()을 빼먹으면 위의 에러가 발생하는 경우가 있더군요. 저는 main()을 누락해서 발생한 오류였습니다.