Reputation: 53
class Display
{
public static void main(String[] args)
{
int x = Integer.parseInt(args[0]);
int y = Integer.parseInt(args[1]);
System.out.println(x+y);
}
}
Terminal :
$java Display 1 2
Exception in thread "main" java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: java/lang/invoke/StringConcatFactory
at Display.main(display.java:7)
Caused by: java.lang.NoClassDefFoundError: java/lang/invoke/StringConcatFactory
... 1 more
Caused by: java.lang.ClassNotFoundException: java.lang.invoke.StringConcatFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
Upvotes: 1
Views: 498
Reputation: 2470
make sure you don't use the openjdk version
but the one provided by oracle:
java -version
should print e.g.
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
and NOT
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.16.04.2-b12)
Upvotes: 0
Reputation: 53
I think there was some problem with the jdk package. I completely removed the packages and did a clean install, and the code worked correctly.
Upvotes: 1