. Advertisement .
..3..
. Advertisement .
..4..
Java is a object-oriented and class-based programming language with as few implementation dependencies as possible.
You got the following error when you ran your code: accessible: module java.base does not “opens java.io” to unnamed module in Java.
We will present workable alternative options to computer programmers due to our research as soon as possible. Let’s get started on fixing this error.
When Does The Error occur?
Situation: I’m learning more about Android programming, so I have built a project of my own, it uses Android studio. Recently I get the following error every time I try to run and build.
Unable to make field private final java.lang.String java.io.File.path accessible:
Unable to make field private final java.lang.String java.io.File.path
accessible: module java.base does not "opens java.io" to unnamed module @42760a00
The simple ways to fix error “accessible: module java.base does not “opens java.io” to unnamed module in Java.”
Here are some of the easiest and most commonly used solutions. You can consult and choose the appropriate solution:
Solution 1: Change the gradle version to 7.1.1
It would help if you had to change the gradle version in the gradle-wrapper properties to 7.1.1 and add this line to gradle.properties.
org.gradle.jvmargs=-Xmx1536M
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
Solution 2: Run command “Flutter doctor”
The other way is run “Flutter Doctor”. If you encounter an error that indicates that Java bundled cannot be located (specially when you’re using Android Studio version Artic Fox) then run these commands on Mac:
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
Solution 3: Downgrade to JDK 8/ JDK 15
Case 1: If you are using JDK 16. To fix your problem, you have to downgrade from JDK 16 to JDK 15.Y
Case 2: You basically have to download and install JDK 8 (1.8).
Change the environment variable (add JDK 8 path to environment variable), then change the project structure and add JDK 8 path to the JDK location.
Restart Android Studio after invalidating caches.
Construct your project, and it should work.
Solution 4: Using android/build.gradle
In android/build.gradle, Check and replace this command line:
classpath("com.android.tools.build:gradle:4.2.2")
By the line:
classpath('com.android.tools.build:gradle:7.0.3')
Conclusion
The solutions presented above are recommendations for those still perplexed by the error “accessible: module java.base does not “opens java.io” to unnamed module in Java”.
If you need support or have a lot of ideas, we have a large community where everyone is usually willing to help. Finally, we would like to thank you, individuals, who have made it this far and wish you a pleasant day of interesting code solutions.
Leave a comment