17

I am using latest version of Intellij Idea and set jdk as 11. When I execute my project it throws exception noclassfoundexception : java.sql.SQLException.

In java compiler settings in Intellij I have mentioned project bytecode version as 11. In project structure settings too, I have set the module jdk as 11.

user3592376
  • 221
  • 1
  • 3
  • 8
  • Just to know better, have you included a `module-info.java` to your project or can you share the project structure and how you are executing? – Naman Oct 25 '18 at 06:26
  • I have not included module-info.java. I am just running the Main class. – user3592376 Oct 26 '18 at 07:18
  • Did Kostiantyn's answer work for you too? If so, it should be accepted, see http://stackoverflow.com/help/someone-answers – Kim Kern Jul 16 '19 at 22:32

1 Answers1

42

Try to change command line shortening method to "JAR manifest".

JAR manifest setting for unit test

I had exactly the same issue after upgrading my project from Java 8 to Java 11. It looks like it is IntelliJ IDEA bug.

Hint for solution taken from here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000022399-Error-running-a-cucumber-test-case-Caused-by-java-lang-NoClassDefFoundError-java-sql-Time

Kostiantyn
  • 935
  • 8
  • 13
  • 2
    In IntellIj top right corner where your tests are run, click "Edit Configurations" to get to the screen above. – Metin Dagcilar Mar 16 '20 at 15:47
  • Did not work for me. I am using JPMS and assuming that the error must be related to modules/dependency management –  May 03 '20 at 19:37
  • This won't work for me but when I tried to run the service it's running. – Abhishek Feb 04 '21 at 18:05