I am surprised that no one has yet suggested javax.lang.model.SourceVersion , because it was actually with Java 1.6.
If you need to check if some string is a reserved keyword, you can simply call:
SourceVersion.isKeyword(str)
And if you really need a complete list of reserved keywords, you can get it from the source code of this class:
private final static Set<String> keywords; static { Set<String> s = new HashSet<String>(); String [] kws = { "abstract", "continue", "for", "new", "switch", "assert", "default", "if", "package", "synchronized", "boolean", "do", "goto", "private", "this", "break", "double", "implements", "protected", "throw", "byte", "else", "import", "public", "throws", "case", "enum", "instanceof", "return", "transient", "catch", "extends", "int", "short", "try", "char", "final", "interface", "static", "void", "class", "finally", "long", "strictfp", "volatile", "const", "float", "native", "super", "while",
Note : the above source code is taken from Java 1.8 , so do not just copy and paste from this post if you are using a different version of Java. Actually, it's probably not a good idea to copy this at all - they made the field private for a good reason - you probably don't want to update it for every new release of Java. But if you absolutely need it, copy it from the source code to your JDK distribution, remembering that you may have to manually update it later.