others-how to solve the `objc: Class is implemented in both` warning when running java program on MACOS?

1. Purpose

In this post, I will demonstrate how to solve the objc: Class is implemented in both warning when running java program on MACOS, here is the detail error message when I tried to run a java program:

run a java problem, got this error:

objc[43909]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java (0x10cf434c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10cfbd4e0). One of the two will be used. Which one is undefined.

The JDK I am using is as follows:

➜  bswen-appweb git:(use_wolib) ✗ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)



2. Solution

Solution: upgrade your java 1.8 to version bigger than 152: goto Java SE Developent Kit to download the latest macos java 1.8 jdk version.

Then change your java home to /Library/Java/JavaVirtualMachines/jdk1.8.0_341.jdk/Contents/Home

➜  ~ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_341.jdk/Contents/Home
➜  ~

Now run the java program again:

/Library/Java/JavaVirtualMachines/jdk1.8.0_341.jdk/Contents/Home/bin/java  com.bswen.appweb.utils.EmailUtilsbw

Process finished with exit code 0



3. Summary

In this post, I demonstrated how to solve the objc: Class is implemented in both warning when running java program on MACOS. The key point is to upgrade your jdk8 version to the latest patch version. That’s it, thanks for your reading.

-->