280

I upgraded to the latest Java 7u40 on MacOS X and started getting the following message on the console when launching my application using Eclipse. The app works fine but I would like to find out the cause of the problem and hopefully a fix for it.

objc[10012]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.

Does anyone know why this message is printed and how to fix it?

Hearen
  • 7,420
  • 4
  • 53
  • 63
ams
  • 60,316
  • 68
  • 200
  • 288
  • Seems like this is also covered in this [post](http://stackoverflow.com/questions/20794751/class-javalaunchhelper-is-implemented-in-both-one-of-the-two-will-be-used-whic), which suggests reverting to u25. – bsquibb Jan 24 '14 at 19:33
  • 3
    While this might be a viable option to remedy this specific kind of problem - this might make you vulnerable to security leaks fixed in u45 and beyond. – Matthias Wenz Jan 26 '14 at 22:20
  • 5
    The same thing is happening with jdk1.8.0_05 – neu242 Jun 13 '14 at 08:39
  • 28
    A year has passed and the bug is still nagging every Java developer that happens to use a Mac (verified with jdk1.7.0_67 on OS X 10.9.3). Shameful. Can anybody with the appropriate login please reopen these bugs http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8021205 and https://bugs.openjdk.java.net/browse/JDK-8025876 – Tobia Sep 05 '14 at 16:06
  • 8
    Bug still exists for jdk1.8.0_25. Is this just a nagging message or an actual problem? – Churk Oct 24 '14 at 03:41
  • 2
    Problem still exists in jdk1.8.0_60 with a slight difference: objc[3457] instead. From my experience in the past year since I last comment, it's did not affect runtime, so I am brushing it off as an annoying message. – Churk Sep 15 '15 at 13:23
  • 7
    A [bug report of this issue](http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8022291) suggests a fix may be included with the JDK9 release. The same bug report says this: "For those who keep asking about this: The message is benign, there is no negative impact from this problem since both copies of that class are identical (compiled from the exact same source). It is purely a cosmetic issue." – Jordan Apr 05 '16 at 14:29
  • All these answers are insufficient because they aren't written in the context of someone using JEnv shims. – djangofan Jul 06 '16 at 18:36

12 Answers12

181

⚠️ For JetBrains IntelliJ IDEA: Go to Help -> Edit Custom Properties.... Create the file if it asks you to create it. To disable the error message paste the following to the file you created:

idea_rt
idea.no.launcher=true

This will take effect on the restart of the IntelliJ.

muttonUp
  • 6,351
  • 2
  • 42
  • 54
  • 2
    The OP was using Eclipse, not IntelliJ. So you're giving them instructions for modifying settings in the wrong editor (hence it not being marked as correct). – Allison Mar 19 '18 at 16:41
  • 2
    I agree with @Allison - if this answer included a means for Eclipse it would be excellent. But answering for the wrong IDE? – Daniel Soutar Apr 16 '18 at 21:17
120

As of October 2017, this issue is now resolved in

Hearen
  • 7,420
  • 4
  • 53
  • 63
muttonUp
  • 6,351
  • 2
  • 42
  • 54
21
  1. Install Java 7u21 from: http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html#jdk-7u21-oth-JPR

  2. Set these variables:

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home
    export PATH=$JAVA_HOME/bin:$PATH
    
  3. Run your app and have fun :)

Aserre
  • 4,916
  • 5
  • 33
  • 56
gotoalberto
  • 555
  • 4
  • 5
  • 3
    Works also for 1.8.0_92: # in .zshrc or .bashrc export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home export PATH=$JAVA_HOME/bin:$PATH – BvuRVKyUVlViVIc7 Jun 13 '16 at 14:10
  • @Lichtamberg thanks this fixed my issues on Java 8 mac osx. I have added your comment as an answer as almost all other answers work but are now absolute. – Pritesh Jain Jun 18 '16 at 11:27
  • 1
    @gotoalberto How will this environment variable solve the issue when both the implementation of the JavaLaunchHelper resides in the Home directory? – Prashant Dec 30 '16 at 07:59
  • 1
    @Lichtamberg I'm using sonar runner to start evaluating code coverage of my app. I'm still getting the same issue with the version you have mentioned above. though I've tried many 8 version with its patches in my mac os. No Luck. – Sathish May 10 '17 at 08:20
  • DO NOT DO THIS. Java 7u21 (besides being released in 2013 and thus having missed out on four years of patches big and small) has a arbitrary code execution vulnerability: https://gist.github.com/frohoff/24af7913611f8406eaf3 – mseebach Jul 31 '17 at 11:11
  • If you installed java via the official .dmg then it should have created a symlink at `/Library/Java/Home` which will point to the correct `JAVA_HOME`, therefore a cleaner approach would be adding to your `~/.bash_profile` something like `export JAVA_HOME=/Library/Java/Home`. Then after upgrading java you won't need to update your `.bash_profile`. – ccpizza Dec 14 '17 at 15:48
11

Copy Pasting @Lichtamberg's comments to gotoalberto's answer

Works also for Java 1.8:

# in ~/.zshrc and ~/.bashrc

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home 
export PATH=$JAVA_HOME/bin:$PATH 

This fixed my issue on java 8.

Pritesh Jain
  • 9,106
  • 4
  • 37
  • 51
5

Not sure if this is the cause of the problem, but I got this issue only after installing JVM Monitor.

Uninstalling JVM Monitor solved the issue for me.

Hearen
  • 7,420
  • 4
  • 53
  • 63
paradite
  • 6,238
  • 3
  • 40
  • 58
4

As other answers detail, this is a bug in the JDK (up to u45) which will be fixed in JDK7u60 - while this is not out yet, you may download the b01 from: https://jdk7.java.net/download.html

It's beta, but fixed that issue for me.

Hearen
  • 7,420
  • 4
  • 53
  • 63
Matthias Wenz
  • 592
  • 4
  • 14
3

https://groups.google.com/forum/#!topic/google-appengine-stackoverflow/QZGJg2tlfA4

From what I've found online, this is a bug introduced in JDK 1.7.0_45. I've read it will be fixed in the next release of Java, but it's not out yet. Supposedly, it was fixed in 1.7.0_60b01, but I can't find where to download it and 1.7.0_60b02 re-introduces the bug.

I managed to get around the problem by reverting back to JDK 1.7.0_25. Probably not the solution you wanted, but it's the only way I've been able to get it working. Don't forget add JDK 1.7.0_25 in Eclipse after installing the JDK.

Please DO NOT REPLY directly to this email but go to StackOverflow: Class JavaLaunchHelper is implemented in both. One of the two will be used. Which one is undefined

Hearen
  • 7,420
  • 4
  • 53
  • 63
Vinod Joshi
  • 7,696
  • 1
  • 50
  • 51
1

To solve this issue, I downgraded to JDK version 1.7.0_21. then I used this little bash script to change the version I use.

function setjdk() {
  if [ $# -ne 0 ]; then
   removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin'
   if [ -n "${JAVA_HOME+x}" ]; then
    removeFromPath $JAVA_HOME
   fi
   export JAVA_HOME=`/usr/libexec/java_home -v $@`
   export PATH=$JAVA_HOME/bin:$PATH
  fi
 }

 function removeFromPath() {
  export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;")
 }

Once you have the bash script in your zshrc/bshrc file, just call setJdk 1.7.0_21 and you're good to go.

Hearen
  • 7,420
  • 4
  • 53
  • 63
guy.gc
  • 3,359
  • 2
  • 24
  • 39
0

Well, after some struggling, what worked for me was completely removing the current JDK, as described here:

sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist
sudo rm -rf /Library/PrivilegedHelperTools/com.oracle.java.JavaUpdateHelper
sudo rm -rf /Library/LaunchDaemons/com.oracle.java.JavaUpdateHelper.plist
sudo rm -rf /Library/Preferences/com.oracle.java.Helper-Tool.plist

Then installed 1.7.0_21, which was downloaded from here.

Now java -version prompts:

java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
Hearen
  • 7,420
  • 4
  • 53
  • 63
demogar
  • 701
  • 1
  • 8
  • 17
0

July 2019

OSX Mojave 10.14.5 (18F132) IntelliJ 2019-1 Community Edition. It worked setting idea.properties file. I also configured JAVA_HOME pointing to /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/

custom IntelliJ IDEA properties

idea_rt idea.no.launcher=true

Community
  • 1
  • 1
Joe V.
  • 769
  • 6
  • 5
-1

If you're using IntelliJ & Mac just go to Project structure -> SDK and make sure that there is Java listed but it points to sth like

/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home

Rather than user home...

kboom
  • 2,279
  • 3
  • 28
  • 43
-3

jdk-7u80-macosx-x64.dmg fix this problem.

wyxiloveu
  • 152
  • 6