2

While trying the freshly released JDK 9, I noticed that it seems to break maven entirely. Even a simple mvn -version won't work:

vgm@localhost:~$ mvn -version
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.launcher.Launcher

When I switch back to openjdk8, it says the maven version is 3.3.9.

I've tried setting JAVA_HOME and MVN_OPTS, but it had no effect. These are my settings:

vgm@localhost:~$ echo $JAVA_HOME 
/usr/java/jdk-9
vgm@localhost:~$ echo $MVN_OPTS
-Dmaven.compiler.fork -Dmaven.compiler.executable=/usr/bin/javac
Naman
  • 27,789
  • 26
  • 218
  • 353
  • 2
    Would suggest updating and trying this out with `3.5.0` installed. Also if you have M2_HOME set, do [follow this.](https://stackoverflow.com/questions/11118237/maven-error-could-not-find-or-load-main-class-org-codehaus-plexus-classworlds-l) – Naman Sep 30 '17 at 07:33
  • Additionally, the MVN_OPTS compiler points to a different javac version ` /usr/bin/javac` in your case, changing that to `/usr/java/jdk-9/bin/javac` might help. Do take a look at https://stackoverflow.com/questions/36583118/is-maven-ready-for-jdk9 – Naman Sep 30 '17 at 07:39
  • `mvn -version` works with `3.5.0`, but the build still fails because maven is trying to find `tools.jar`. The javac path is a softlink, it's pointing to the correct location. – KraftDurchBlumen Sep 30 '17 at 07:45
  • *The build still fails*.. there is no detail over a build failure in the question as of now. Also if you're trying to build a project, can you share the `` information of its pom.xml? – Naman Sep 30 '17 at 07:46
  • You're right, it's working fine on a minimal example project. I'll make a new question if I get stuck again. Thanks! – KraftDurchBlumen Sep 30 '17 at 07:57
  • Sure, please close this in that case. :) – Naman Sep 30 '17 at 07:58
  • Couldn't figure out how to close, except by answering my own question. But I can only accept that in 2 days :/ – KraftDurchBlumen Sep 30 '17 at 08:06
  • I guess there is a limit of reputation to do so. But marking a comment as an answer isn't good either. – Naman Sep 30 '17 at 08:08
  • Failing to find `tools.jar` means that you build tries to get this which will not work in JDK 9...furthermore the problem is related to the old plugins not to Maven itself. Maven 3.3.9 etc. will only plugins are causing this...This means also you haven't pinned the versions of your plugins correctly. Apart from that I assume you have set `M2_HOME` etc. Only entry in PATH is really necessary. Nothing else. – khmarbaise Sep 30 '17 at 11:52

1 Answers1

2

As nullpointer suggested, I updated to Maven 3.5.0, and it works now.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574