0

I am writing a database management program in java in maven in intellij IDEA. For now, the code is only connecting me to the database in MySQL. The code itself has no errors. However, upon running it, the following error comes: java: package com.sun.tools.javac.code is not visible (package com.sun.tools.javac.code is declared in module jdk.compiler, which does not export it to the unnamed module)

I have not explicitly imported the package. I am not an advanced programmer and have no idea how to solve this issue.

According to ChatGPT, the problem may be due to the jdk version I am using i.e Oracle Open jdk version 20. How do I solve this?

3
  • That error message means that you are using a class from the package com.sun.tools.javac.code that you are not allowed to use. To fix it you must change your code so that it no longer uses that class. Search for the package name (com.sun.tools.javac.code) in your code to find the places where you use that class. Commented Apr 18, 2023 at 17:42
  • This is related to the Java Platform Module System (JPMS), which was added in Java 9. If you don't know what that is, check out Understanding Java 9 Modules for an introduction. The error is stating that you're using a type from the com.sun.tools.javac.code package, which the jdk.compiler module does not exports. This is illegal, and likely means you need to change your code. If you must have access to those types, then look into using --add-exports.
    – Slaw
    Commented Apr 18, 2023 at 18:28
  • That said, when is this error being thrown? During compile-time, or during run-time? If the former, please provide the full error in yoru question. If the latter, then that error should have been accompanied by a stack trace; please add it to your question.
    – Slaw
    Commented Apr 18, 2023 at 18:32

0

Browse other questions tagged or ask your own question.