2

I want to use jdk.internal.net.http.common.Pair and I am getting this error when running my project :

Caused by: java.lang.IllegalAccessError: class com.pacman.controller.SignUpMenuController (in unnamed module @0x51565ec2) cannot access class jdk.internal.net.http.common.Pair (in module java.net.http) because module java.net.http does not export jdk.internal.net.http.common to unnamed module @0x51565ec2

I looked into this question : Gradle run with `--add-exports`

and since my project is not modular what exactly should I add in my project build.gradle file?

and when I add :

run {
jvmArgs = ['--add-exports=java.net.http/jdk.internal.net.http = All-UNNAMED']}

to my desktop/build.gradle file I still get the same error.

Hasti
  • 51
  • 5
  • 1
    Does this answer your question? [Use jdk.internal.net.http](https://stackoverflow.com/questions/53998482/use-jdk-internal-net-http) – Silvio Mayolo May 31 '21 at 15:56
  • @SilvioMayolo not exactly. Actually when I add the run that way, I will get another error which I will add it now. – Hasti May 31 '21 at 16:12
  • I believe you should either build project using classpath like in get started example: https://docs.gradle.org/current/samples/sample_building_java_applications.html or properly make your project modular by adding module-info.java with something like: module com.pacman { requires java.net.http; } and build it like gradle build -Pmodule=com.pacman – JustK K Jun 01 '21 at 05:09

0 Answers0