Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ target bytecode reverting

For a project that I'm currently working on, IntelliJ gave me the compile error Error:java: javacTask: source release 8 requires target release 1.8. I went into Settings>Build, Execution, Deployment>Compiler>Java and saw that the target bytecode version for one of my modules was set to 1.5, so I changed it to 1.8, compiled, and it worked. But then the next day, I got the same error. I went into settings and the target bytecode for that one module was back at 1.5. I changed it to 1.8 and it compiled/ran just fine. This has now happened multiple times and I am frustrated by the number of times I have to go into settings to manually change the target bytecode version.

Why does the target bytecode version keep reverting? I don't have 1.5 specified in the pom or anywhere else, so I am baffled as to why the bytecode version keeps getting set to 1.5.

like image 807
dallinski Avatar asked Oct 29 '15 18:10

dallinski


People also ask

How do I change the target bytecode version in IntelliJ?

I went into Settings>Build, Execution, Deployment>Compiler>Java and saw that the target bytecode version for one of my modules was set to 1.5, so I changed it to 1.8, compiled, and it worked.

How do I change the source level in IntelliJ?

From the main menu, select File | Project Structure Ctrl+Alt+Shift+S . Under Project Settings, select Modules | Sources. From the Language level list, select the necessary option. To use the project language level, select Project default.

Does IntelliJ use Javac?

Javac. This may be the compiler included in the IntelliJ IDEA distribution or a compiler from one of the project JDKs. Eclipse (also known as Eclipse Compiler for Java or ECJ). IntelliJ IDEA comes bundled with the Eclipse compiler.

What is byte code version?

2. What Is the Bytecode? Bytecode is the intermediate representation of a Java program, allowing a JVM to translate a program into machine-level assembly instructions. When a Java program is compiled, bytecode is generated in the form of a . class file.


1 Answers

You need to specify the source and target versions in your pom.xml file, but since the maven-compiler-plugin is added by default, an easier way to do that would be to set the following properties:

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>
like image 54
isapir Avatar answered Sep 28 '22 01:09

isapir