0

I'm trying to run a program with the following structure:

+src
    +gui
        -XL.java
        -moreFiles.java
        +menu
            -guiFiles.java
    +util
        -utilFiles.java
    +extra
         -extraFiles.java

I'm trying to compile the code by calling

javac gui/XL.java

Which succeeds. When I try running the code with

java gui.XL

I get the following error message:

Exception in thread "main" java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: java/lang/invoke/StringConcatFactory
    at gui.XL.<init>(XL.java:25)
    at gui.XL.main(XL.java:58)
Caused by: java.lang.NoClassDefFoundError: java/lang/invoke/StringConcatFactory
    ... 2 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)
    ... 2 more

I guess I have some problems with my classpath but I have no clue about how to fix it. Does anyone have any suggestions?

RykteT
  • 1
  • 3
  • 1
    You have to compile all the .java source files to .class files, not just one. – duffymo Sep 30 '17 at 15:38
  • That's a Java 9 class did you install java 9? – Oleg Sep 30 '17 at 15:45
  • @duffymo: When I compile all the .java files first I get the same error. – RykteT Oct 01 '17 at 09:05
  • @Oleg: When I check my java version (with sudo update-alternatives --config java) I get that I have java-8-openJDK and java-9-openJDK on my computer and I have tried both. None of them works. But it says that my java version is "9 internal" (whatever that means). When I use the "9-internal" version I get a java runtime environment crashdump instead of the error posted above for java-8-openjdk. – RykteT Oct 01 '17 at 09:07

1 Answers1

0

My problem had nothing to do with classpaths or that I wasn't using an IDE. My problem came from the fact that I was changing the 'java' command to run my java-openjdk-8 but my compiler still ran with java-openjdk-9. The solution was therefore

sudo update-alternatives --config javac #Change to java 8
sudo update-alternatives --config java #Change to java 8
RykteT
  • 1
  • 3