I'm working on a simple Java project and trying to use IntelliJ 14 for the first time; I have the Ultimate version through an education license (in my last year of undergrad!). I'm not super familiar with either Maven or IntelliJ. I want to use Java 8, and in fact I'm pretty sure this is the only version of the JDK I have installed on my computer. However, whenever I compile my project, I get a couple warnings and an info message:Information: Using javac 1.8.0_51 to compile java sources
Warning: java: source value 1.5 is obsolete and will be removed in a future release
Warning: java: target value 1.5 is obsolete and will be removed in a future release
So what I've noticed is that under IntelliJ IDEA > Preferences... > Build, Execution, Deployment > Compiler > Java Compiler, the target bytecode version is set to 1.5
. I can change it to 1.8
, but when I quit IntelliJ and re-open the project, it is reset to 1.5
. The project bytecode version is blank for SDK default.
Here's what I've already done:
included the following in my maven pom
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Changed the IntelliJ preference file as noted here on the IntelliJ website.
Set the global, project, and module SDK as noted here on the IntelliJ website.
Am I missing a setting somewhere? What do I have to do to keep this value from changing every time I re-open IntelliJ?
I'm using IntelliJ IDEA 2017.2. To build the project (using Ctrl+F9), changing the maven-compiler-plugin
source and target versions was not enough.
I had to:
Then I ran into this other problem. To solve it, I had to:
Aside: I've been using IDEs since Turbo Pascal 2.0 in the 80s. I find it counter-intuitive that such a modern IDE makes it so hard to open the "Project Settings". First, if you right-click the project (top left on the main window) there's no option to open project settings. Second, the "Project" bar on the top left of the main window has the gear symbol with a drop-down list, but no option to access project settings there either. Third, if you right-click the project directory in the project explorer view on the left, you see "Open Module Settings" but there's no "Project Settings". Fourth, if you open File on the main menu, you'll see "Settings", "Other Settings" but no "Project Settings". Counter-intuitive. :^|
Try using the maven compiler plugin in your pom.xml
and set the source/target level accordingly. IDEA will change the project settings according to this setting
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With