question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

java.lang.NoClassDefFoundError: java/util/function/BiFunction

See original GitHub issue

using lingua version :

<dependency>
	<groupId>com.github.pemistahl</groupId>
	<artifactId>lingua</artifactId>
	<version>1.0.1</version>
</dependency>

using code :

private static final LanguageDetector detector =
		LanguageDetectorBuilder.fromLanguages(Language.KOREAN, Language.JAPANESE).build();
detector.computeLanguageConfidenceValues("안녕하세요");

error message :

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

java.lang.NoClassDefFoundError: java/util/function/BiFunction

	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	at com.github.pemistahl.lingua.api.LanguageDetector.addCharCount(LanguageDetector.kt:409)
	at com.github.pemistahl.lingua.api.LanguageDetector.detectLanguageWithRules$lingua(LanguageDetector.kt:234)
	at com.github.pemistahl.lingua.api.LanguageDetector.computeLanguageConfidenceValues(LanguageDetector.kt:145)
	at com.github.pemistahl.lingua.api.LanguageDetector.detectLanguageOf(LanguageDetector.kt:100)
	at com.naver.labs.smt.api.translator.bo.TranslatorBoTest.test(TranslatorBoTest.java:25)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: java.lang.ClassNotFoundException: java.util.function.BiFunction
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	... 39 more

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pemistahlcommented, Aug 2, 2020

Hi @levant916, thank you for using Lingua and for opening this issue.

I can confirm that this is a bug. This is because the LanguageDetector uses the Java method java.util.Map.merge() internally which is only supported by Java >= 1.8. I will replace it by an appropriate Kotlin method. After this change, the library should run on Java 1.6 and 1.7 as it was originally intended.

Only the FilesWriter classes will need Java 1.8 at least because I make use of the NIO api. But if you don’t want to create your own language models, you should be fine with Java < 1.8.

0reactions
pemistahlcommented, Aug 3, 2020

@roi3363 Can you please open a new issue for your specific problem? In that new issue, please state your project configuration including your build script if any, including any third-party dependencies you are using. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception in thread "main" java.lang.NoClassDefFoundError
util.function.Predicate is part of JavaSE8 and will not be available in 1.7 some of the set commands to use before executing maven command....
Read more >
How do I resolve a java.lang.NoClassDefFoundError error ...
NoClassDefFoundError error while attempting to create a connection pool while installing and configuring REST Services when using Java 11+? ...
Read more >
Java 8 library desugaring causes getDeclaredMethods() to ...
Java 8 library desugaring causes getDeclaredMethods() to throw NoClassDefFoundError when called on an Iterable.
Read more >
NoClassDefFoundError (Java Platform SE 8 )
Constructs a NoClassDefFoundError with the specified detail message. Method Summary. Methods inherited from class java.lang.Throwable · addSuppressed, ...
Read more >
BiFunction | Android Developers
This is a functional interface whose functional method is apply(java.lang. ... BiFunction<T, U, V>, a composed function that first applies this function and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found