Idea: javac: source release 1.7 requires target release 1.7
Rapidly resolve the javac
error by harmonising your Java source and target versions with the -source
and -target
flags both set to 1.7:
In IntelliJ IDEA, tweak the Project language level to 7 under Project Settings and make sure the Java Compiler's Target bytecode version also dances to the same tune.
Setting the stage with Maven
If you're rendezvousing with Maven, ensure in your pom.xml
both maven.compiler.source
and maven.compiler.target
properties are dressed for the party, i.e., set to 1.7. Especially since Maven's default language level is 1.5. The maven-compiler-plugin
needs an upgrade too:
Summon IntelliJ IDEA to reimport the Maven settings for a grand reunion.
Tightening the IntelliJ screws
Navigate your ship in IntelliJ IDEA to File > Settings > Build, Execution, Deployment > Compiler. This is where you ensure the Java Compiler path and module settings are in sync with Java 1.7.
Don't forget to cross-check IntelliJ's Module SDK and the Maven compiler plugin version in the pom.xml
, they need to agree on JDK 7 compatibility. Resolve any cognitive dissonance in your IntelliJ module settings to the Java Compiler version 1.7 to cast away the "source requires target" error haunting your code.
Maven's ninja moves on IDE
If Maven builds have mastered the art of transformation but the same magic fails in your IDE, examine IntelliJ's unique configuration rituals. Double-check that both the Project Structure settings and the Module settings' SDK version in IntelliJ align with your Maven settings.
Consistency: The secret sauce
Just like in cooking, consistency is the name of the game. Ensure coherence in SDK version, module language level, and bytecode version across the landscape of IntelliJ IDEA and Maven configurations.
Maven freshness
Stale bread is a no-no in a sandwich. Likewise, ensure you're using the freshest Maven 3 and JDK 7 to construct a functional and efficient build environment.
Was this article helpful?