"Could not find or load main class java.se.ee" while running sdkmanager --licences
Asked Answered
M

5

23

When building my project on android studio, it asks me to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.

When I run "./sdkmanager --licenses", I have the "Could not find or load main class java.se.ee" error.

I found a lot of similar issues on stackoverflow, but non of the solutions provided worked for me.

I already tried: 1- downgrade to java 8

2- export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'

3- change sdkmanager file by adding : DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'

Microsurgery answered 21/1, 2019 at 10:9 Comment(2)
Hi have you fixed this issue?Actaeon
This issue still coming... have u fixed it ?Superstar
P
53

I had the same issue.
And solved by following the below steps:

1) Install java 8

2) Run command in terminal

unset JAVA_OPTS

3) Then run command in terminal

./sdkmanager --licenses

Pleach answered 6/5, 2019 at 6:8 Comment(4)
Running the second point which is unset JAVA_OPTS did the trick. Thanks.Actaeon
how to unset JAVA_OPTSSuperstar
This worked nicely. The key was ./sdkmanager --licenses thanks!Macready
On Windows I ran this in the command line to unset JAVA_OPTS set JAVA_OPTS=Spindling
A
19

Well, it's been 4 months since you asked the question. You must have found the answer, but here is a way easy solution for others who are still looking for it:

JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions'

And, Voila the issue is solved!

Why this solved the problem?

Well I don't know the exact reason but, I also don't know why we tend to add java.se.ee through "--add-modules java.se.ee", I tried removing it and error was gone! Maybe because java11 removed EE module, and it was depreciated in java10.

It was just a blind shot which worked!, If anyone knows the proper reason please comment it out!

Adkinson answered 19/6, 2019 at 11:43 Comment(1)
I have upvoted you answer as it was helpful! But can you explain why did this error occurred and what does your solution do? It would be really helpful.Campos
N
8

Unsetting JAVA_OPTS worked for me.


 1. unset JAVA_OPTS
 2. sdkmanager --list
 3. sdkmanager "platform-tools" "platforms;android-28"

Nassi answered 2/8, 2019 at 10:50 Comment(2)
unset is not recognised as internal or external command on my caseSuperstar
zsh: command not found: sdkmanager - Terminal can;t able to find this commandCriminal
I
2

Below steps helped me get past above Java error.

JDK Version:

sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
* 2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: <Choose Java 8>

Procedure:

  1. unset JAVA_OPTS
  2. In folder ~/Android/Sdk/tools/bin$ sudo nano ./sdkmanager
  3. Change line# 31 to

DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions'

  1. Save the file and exit
  2. ./sdkmanager --list

    Installed packages:=====================] 100% Computing updates...
    Path | Version | Description | Location
    ------- | ------- | ------- | -------
    build-tools;29.0.2 | 29.0.2 | Android SDK Build-Tools 29.0.2 | build-tools/29.0.2/

Inapplicable answered 28/11, 2019 at 4:25 Comment(0)
N
2

After struggling to install platform tools from sdk manager with related errors

"Error occurred during initialization of boot layer java.lang.module.FindException: Module java.se.ee not found"

  1. I first downgraded to Java 8 and then set Java 8 as default Java(JDK) How to set or change default Java(JDK):

  2. I tried installing platform tools again.

    sdkmanager "platform-tools" "platforms;android-28"

But then I got the error mentioned above. "Error: Could not find or load main class java.se.ee"

My search brought me here and

unset JAVA_OPTS
sdkmanager "platform-tools" "platforms;android-28"

This was the most closely related problem with a solution I could find and it helped me install platform-tools.

Nutgall answered 31/1, 2020 at 22:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.