IntelliJ compile for Java 7 JRE using Java 8 SDK

12,710

Solution 1

File -> Settings -> Compiler -> Java Compiler -> Project bytecode version -> 1.7

Solution 2

  • Select root of your project.
  • Press F4
  • Select language level.

enter image description here

Share:
12,710

Related videos on Youtube

arik
Author by

arik

Working on bitcoin.

Updated on June 10, 2022

Comments

  • arik
    arik almost 2 years

    I have the Java 8 SDK and runtime, and a project that is only using Java 7 features. I was wondering whether I could set up intellij to build a Java-7-level jar, something that is definitely possible from command line?

    So far, I have tried simply setting the project language level to 7 as an experiment, but that is obviously insufficient and not really what I need.

    I have also seen this question on SO: "Intellij IDEA using java7 compiler to compile when I have configured it to use Java6", but my project SDK is already set up to the newest Java version, and I merely need a Java-7-compatible artifact/jar compilation.

    EDIT: I only have Java 6 and Java 8 JREs/SDKs on my local system because unfortunately Java 7 has issues on my system and is not compatible.

    • EpicPandaForce
      EpicPandaForce almost 10 years
      I think you need to set the project language level. Eclipse could do this too using a lower version compiler, so I'm fairly certain IntelliJ can do it too.
    • arik
      arik almost 10 years
      I've already tried that, but it didn't work. (See 2nd paragraph)
    • Vishy
      Vishy almost 10 years
      Can you clarify "that is obviously insufficient and not really what I need." Which build tool are you using e.g. ant or maven?
    • EpicPandaForce
      EpicPandaForce almost 10 years
      ah, found it, I'll post an answer
  • Benjamin R
    Benjamin R over 9 years
    You have to have this set as well really to actually solve the OP's problem. It certainly solved it for me.
  • Prabo
    Prabo over 5 years
    You saved my day