Tag Archives: JNI error

[Solved] JNI Error: Fatal signal 11 (SIGSEGV)

2022-09-14 09:19:01.092 3562-3580/com.derry.opengl A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x24 in tid 3580 (GLThread 103) 

I often encounter this kind of error report, making me very bummed.

I tried a solution (rooted phone or emulator, otherwise the error log file can not be found): 1.

1. find the file where the logs are located: data/tombstones

2. Find the file with this latest date

3. save the file to the desktop (I did not encounter problems with permissions using the emulator, so I can export directly) If you encounter insufficient permissions, you need to use su superuser permissions (chmod 777 xxxxx)

4. open the log file: there are error logs inside (this point is not enough permissions for me) specific analysis of the problem, this point is mainly to explain how to view this log file

--------- log main 09-14 09:18:58.184 3562 3562 D : houdini no need remount 09-14 09:18:58.201 3562 3562 I art : Late-enabling -Xcheck:jni 09-14 09:18:58.236 3562 3562 E libnb : load libnb 09-14 09:18:58.252 3562 3562 D houdini : [3562] Initialize library(version: 7.1.1b_x.49852 RELEASE)... successfully. 09-14 09:18:58.254 3562 3562 W art : Unexpected CPU variant for X86 using defaults: x86 09-14 09:18:58.719 3562 3562 W art : Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 09-14 09:18:58.782 3562 3562 I art : Rejecting re-init on previously-failed class java.lang.Class: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener; 09-14 09:18:58.783 3562 3562 I art : at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.widget.ActionBarContainer.(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance0!( java.lang.Object[]) (Constructor.java:-2) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflate(org.xmlpull.v1. XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1. XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1. XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377) 09-14 09:18:58.783 3562 3562 I art : at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140) 09-14 09:18:58.783 3562 3562 I art : at void com.derry.opengl.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:19) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6692) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118) 09-14 09:18:58.783 3562 3562 I art : at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2621) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2729) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1480) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Looper.loop() (Looper.java:154) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6176) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Method.invoke!( java.lang.Object, java.lang.Object[]) (Method.java:-2) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:893) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:783) 09-14 09:18:58.783 3562 3562 I art : Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.derry.opengl-1/base.apk"],nativeLibraryDirectories=[/data/app/com.derry.opengl-1/lib/arm, /data/app/com.derry.opengl-1/base.apk! /lib/armeabi-v7a, /system/lib, /vendor/lib]] 09-14 09:18:58.783 3562 3562 I art : at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312) 09-14 09:18:58.783 3562 3562 I art : at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.widget.ActionBarContainer.(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance0!( java.lang.Object[]) (Constructor.java:-2) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflate(org.xmlpull.v1. XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858) 09-14 09:18:58.783 3562 3562 I art : at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1. XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1. XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426) 09-14 09:18:58.783 3562 3562 I art : at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377) 09-14 09:18:58.783 3562 3562 I art : at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466) 09-14 09:18:58.783 3562 3562 I art : at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140) 09-14 09:18:58.783 3562 3562 I art : at void com.derry.opengl.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:19) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6692) 09-14 09:18:58.783 3562 3562 I art : at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118) 09-14 09:18:58.783 3562 3562 I art : at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2621) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2729) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1480) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102) 09-14 09:18:58.783 3562 3562 I art : at void android.os.Looper.loop() (Looper.java:154) 09-14 09:18:58.783 3562 3562 I art : at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6176) 09-14 09:18:58.783 3562 3562 I art : at java.lang.Object java.lang.reflect.Method.invoke!( java.lang.Object, java.lang.Object[]) (Method.java:-2) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:893) 09-14 09:18:58.783 3562 3562 I art : at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:783) 09-14 09:18:58.783 3562 3562 I art : 09-14 09:18:58.843 3562 3562 W System.err: java.io.FileNotFoundException: /sdcard/lbpcascade_frontalface.xml (Permission denied) 09-14 09:18:58.844 3562 3562 W System.err: at java.io.FileOutputStream.open(Native Method) 09-14 09:18:58.844 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:221) 09-14 09:18:58.844 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:169) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.utils.FileUtil.copyAssets2SDCard(FileUtil.java:16) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MyGLRenderer.(MyGLRenderer.java:43) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.init(MyGLSurfaceView.java:29) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.(MyGLSurfaceView.java:21) 09-14 09:18:58.844 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance0(Native Method) 09-14 09:18:58.844 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.createView(LayoutInflater.java:645) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 09-14 09:18:58.844 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 09-14 09:18:58.844 3562 3562 W System.err: at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 09-14 09:18:58.844 3562 3562 W System.err: at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 09-14 09:18:58.844 3562 3562 W System.err: at com.derry.opengl.MainActivity.onCreate(MainActivity.java:19) 09-14 09:18:58.844 3562 3562 W System.err: at android.app.Activity.performCreate(Activity.java:6692) 09-14 09:18:58.845 3562 3562 W System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 09-14 09:18:58.846 3562 3562 W System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621) 09-14 09:18:58.846 3562 3562 W System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2729) 09-14 09:18:58.846 3562 3562 W System.err: at android.app.ActivityThread.-wrap12(ActivityThread.java) 09-14 09:18:58.847 3562 3562 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1480) 09-14 09:18:58.848 3562 3562 W System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 09-14 09:18:58.848 3562 3562 W System.err: at android.os.Looper.loop(Looper.java:154) 09-14 09:18:58.848 3562 3562 W System.err: at android.app.ActivityThread.main(ActivityThread.java:6176) 09-14 09:18:58.848 3562 3562 W System.err: at java.lang.reflect.Method.invoke(Native Method) 09-14 09:18:58.848 3562 3562 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893) 09-14 09:18:58.848 3562 3562 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783) 09-14 09:18:58.857 3562 3562 W System.err: java.io.FileNotFoundException: /sdcard/seeta_fa_v1.1.bin (Permission denied) 09-14 09:18:58.862 3562 3562 W System.err: at java.io.FileOutputStream.open(Native Method) 09-14 09:18:58.862 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:221) 09-14 09:18:58.862 3562 3562 W System.err: at java.io.FileOutputStream.(FileOutputStream.java:169) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.utils.FileUtil.copyAssets2SDCard(FileUtil.java:16) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.MyGLRenderer.(MyGLRenderer.java:45) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.init(MyGLSurfaceView.java:29) 09-14 09:18:58.862 3562 3562 W System.err: at com.derry.opengl.MyGLSurfaceView.(MyGLSurfaceView.java:21) 09-14 09:18:58.862 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance0(Native Method) 09-14 09:18:58.862 3562 3562 W System.err: at java.lang.reflect.Constructor.newInstance(Constructor.java:430) 09-14 09:18:58.862 3562 3562 W System.err: at android.view.LayoutInflater.createView(LayoutInflater.java:645) 09-14 09:18:58.862 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) 09-14 09:18:58.862 3562 3562 W System.err: at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:518) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:426) 09-14 09:18:58.863 3562 3562 W System.err: at android.view.LayoutInflater.inflate(LayoutInflater.java:377) 09-14 09:18:58.863 3562 3562 W System.err: at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 09-14 09:18:58.863 3562 3562 W System.err: at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 09-14 09:18:58.863 3562 3562 W System.err: at com.derry.opengl.MainActivity.onCreate(MainActivity.java:19) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.Activity.performCreate(Activity.java:6692) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2729) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.-wrap12(ActivityThread.java) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1480) 09-14 09:18:58.863 3562 3562 W System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 09-14 09:18:58.863 3562 3562 W System.err: at android.os.Looper.loop(Looper.java:154) 09-14 09:18:58.863 3562 3562 W System.err: at android.app.ActivityThread.main(ActivityThread.java:6176) 09-14 09:18:58.863 3562 3562 W System.err: at java.lang.reflect.Method.invoke(Native Method) 09-14 09:18:58.863 3562 3562 W System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893) 09-14 09:18:58.863 3562 3562 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783) 09-14 09:18:58.998 3562 3562 D : static HostConnection *HostConnection::createUnique(): call 09-14 09:18:58.999 3562 3562 D : HostConnection::get() New Host Connection established 0xd2dfcd30, tid 3562 09-14 09:18:59.103 3562 3586 I OpenGLRenderer: Initialized EGL, version 1.4 09-14 09:18:59.103 3562 3586 D OpenGLRenderer: Swap behavior 1 09-14 09:18:59.105 3562 3586 D : HostConnection::get() New Host Connection established 0xd2dfcf10, tid 3586 09-14 09:18:59.416 3562 3580 D : HostConnection::get() New Host Connection established 0xd7012480, tid 3580 09-14 09:18:59.794 3562 3580 E EGL_emulation: eglQueryContext 32c0 EGL_BAD_ATTRIBUTE 09-14 09:18:59.794 3562 3580 E EGL_emulation: tid 3580: eglQueryContext(1413): error 0x3004 (EGL_BAD_ATTRIBUTE)

Error: a JNI error has occurred, please check your installation and try again

Java files do not report an error, but Java does report an error when it is run
Take a closer look at the error message
Exception in thread “main” java.lang.UnsupportedClassVersionError: The helloworld has had been compiled by a more recent version of the Java Runtime (class file version 54.0), and this version of the Java Runtime only recognizes the class file versions up to 52.0
Check the cause and find that the Java version is inconsistent with the JavAC version.
Java-version and Javac-Version, indeed
The two versions do not agree
Solution:
1. Query how many Java versions are in Linux

rpm -qa |grep java

2. Then delete them one by one

rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.181-3.b13.el7_5.x86_64
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.171-2.6.13.0.el7_4.x86_64
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.171-2.6.13.0.el7_4.x86_64
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64 
Enter rpm --e --nodeps + "existing version of java") Delete as many as you can.

3. Verify that all the original Java versions have been removed

[root@yuan 8-1]# java - version
-bash: /usr/bin/java: No such file or directory

4. Configure newly installed Java environment variables after the original version is removed

vi /etc/profile 

Edit the profile file and add it at the end

JAVA_HOME=/usr/local/java/jdk-10.0.2/   ###(“jdk-10.0.2" is changed to the name of the installation file of the java version you want to install.)
JRE_HOME=$JAVA_HOME/           ###(As there is no jre folder after jdk10 unzip, if it is below jdk10 version, you should
                               forJRE_HOME=$JAVA_HOME/jre”)
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
export JAVA_HOME JRE_HOME PATH CLASSPATH

5. Last update

source /etc/profile

complete