Failed when running java: Exception in thread "main" java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder


#1

I am trying to package android , but getting following error :

 Failed when running java: Exception in thread "main" java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder
	at com.android.sdklib.internal.build.SignedJarBuilder.<init>(SignedJarBuilder.java:172)
	at io.trigger.forge.ApkSigner.main(ApkSigner.java:125)
Caused by: java.lang.ClassNotFoundException: sun.misc.BASE64Encoder
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	... 2 more 

I found few topic of discussion on this issues like : this or this . My current version of java 11.0.1 I guess which is causing the issue . One thread was saying for downgrade java version. But is there any cleaner way to resolve this issue ?


#2

There is not. And removing 11 or 12 is a test of one’s patience.

I had to follow all the easily-found steps to remove what’s there.
Reboot.
Install 8.
Reboot.
Remove those steps AGAIN.
Reboot.
Reinstall 8.
Reboot.
Then reinstall the Trigger Toolkit.

Yes. No exaggeration. Finally, that’s what it took. On a Mac.

$*ck Java.


#3

I have downgraded Java version .Now my java version is “1.8.0_211”. But still getting same issue.


#4

This is of little or no help. I know this. But my observations trying to get my system fixed were these…

  1. removing 11 or 12 is really only just covering it up. I don’t think it ever really comes off.
  2. manually find every java executable on your machine, most notably find java and javac executables, and all the binaries in their directories. Verify you don’t have any 11 or 12 versions left hanging around, and if you do, either manually delete them and create your own simlinks back to ver 8, or at the very least, ensure where ever you find them is NOT in the path, or is referenced in any bash or other batch/command files.
  3. and I don’t mean to harp on this, reboot, reboot, reboot every step of the way on the uninstall and reinstall. Every step. It took me DAYS, morning to night, to get Forge working properly again after my Java upgrade. Like, drop everything and fix this because OMFG it’s an emergency at this point kind of stress level.

Antoine is going to have to address the Java level issue at some point. :frowning: