5

Edit - this is solved - the issue was solved by setting: "Settings -> Build, Execution, Deployment - Java Compiler -> Project Bytecode Version : 9"

I'm following the example/tutorial at https://www.logicbig.com/tutorials/core-java-tutorial/modules/getting-started-in-intellij.html

This is NOT a maven project. I have set the source level to 9 in the project structure eg

enter image description here

I have set the project level to 9:

enter image description here

I am getting "Error:(3, 4) java: modules are not supported in -source 8 (use -source 9 or higher to enable modules)" error when trying to build/run the project's main class.

And yes I have seen Intellij IDEA 2018.1 Jdk10 cannot run test which is unanswered.

I have just updated Intellij to 2019.2.4 but the issue remains. I am using SDK 11. How can this be fixed? Thanks.

Edit: the Run/Debug configuration options:

enter image description here

Edit: the error:

enter image description here

Edit: the platform SDK:

enter image description here

Edit: the dependencies panel:

enter image description here

FWIW, the contents of the iml files show language level 9:

<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_9" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
</module>

<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_9" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="module" module-name="common.widgets" />
  </component>
</module>
9
  • Check the configuration that is used for building / running. You should have an "edit configuration" button somewhere on the top bar near the run button. Check if the SDK and parameters used there are ok. Commented Nov 4, 2019 at 13:18
  • Thanks but (under the "Application" dropdown on the LHS pane) there's no SDK option; there is a JRE option and it's set to "Default (11 - SDK of 'data.widget' module).
    – JL_SO
    Commented Nov 4, 2019 at 13:23
  • Where do you see that error?
    – Andreas
    Commented Nov 4, 2019 at 13:25
  • In the Messages pane at the bottom of the screen.
    – JL_SO
    Commented Nov 4, 2019 at 13:27
  • Can you check the Dependencies tab in "Project Structure > Modules"? You can set the module SDK there. Commented Nov 4, 2019 at 13:37

2 Answers 2

9

This is solved - the issue was solved by setting: "Settings -> Build, Execution, Deployment - Java Compiler -> Project Bytecode Version : 9"

Thanks to all who gave their time to try to help.

0

Set SDK

I think you must be setting SDK under Platform Setting in project structure

enter image description here

6
  • No, I have 11 there (as well as 8). I append/paste the screenshot to the question.
    – JL_SO
    Commented Nov 4, 2019 at 13:31
  • No! you haven't put snapshot of SDK. what you have shared is project settings Commented Nov 4, 2019 at 13:33
  • Also, can you do a java -version on your intellij terminal? Commented Nov 4, 2019 at 13:33
  • Sorry, I misunderstood your statement. In any case, I think you can see that I have set everything everywhere in Intellij at least to either 9 or 11. But as for java -version in the Terminal window in intellij, that reports version 8: $ java -version openjdk version "1.8.0_222"...
    – JL_SO
    Commented Nov 4, 2019 at 13:37
  • Can you change terminal version to 11 ? I know this shouldn't be the case but just to see if it works Commented Nov 4, 2019 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.