Fork me on GitHub
peter hull12:05:48

Should leiningen 2.8.1 work with JDK 9 & 10 on Linux?

peter hull12:05:30

I am getting "Java compiler not found; Be sure to use java from a JDK rather than a JRE by modifying PATH or setting JAVA_CMD." on a project with Java in it.

peter hull12:05:02

(This is Fedora 28)

peter hull12:05:56

More info - in JShell I get this: jshell> ToolProvider.getSystemJavaCompiler() $2 ==> [email protected] But in lein repl, this: user=> ( nil JDK 1.8.0 is OK, so I've switched to that.


@peterhull90 I haven’t tried and it’s not immediately clear from this thread;


From the news I would assume there’s some compatibility so it might be down to the specific plugins you’re using.

peter hull20:05:27

Thanks @nfisher! I did see that bug and it looked different to what I'm seeing. I admit I didn't spend long but it seemed like lein basically worked with JDK9/10 (lein repl was fine, etc.) but could not invoke javac. I cannot believe I'm the only person to have tried it, so, you may well be right to suggest it's something to do with my plugins. Will investigate further.


Are you sure you have the JDK of 1.9 and not just the JRE ? 😛

peter hull07:05:16

I am fairly sure I have JDK10 installed:

peter hull07:05:19

[[email protected] ~]$ dnf list installed |grep java-openjdk java-openjdk.x86_64 1: @updates java-openjdk-devel.x86_64 1: @updates java-openjdk-headless.x86_64 1: @updates [[email protected] ~]$ javac -version javac 10

peter hull07:05:28

Also I don't understand why returns an instance of in jshell and nil in lein repl


Well, it is possible you have the two tools configured to a different location of the jdk vs jre, but I’m not sure what may be the issue


perhaps set JAVA_CMD for lein to whatever the jshell is using to be sure that isn’t the case

peter hull19:05:03

I'm thinking it's a module thing - the javadocs say it might return null if jdk.compiler module is not available: so may be some way to specify java modules to lein?


Ah yeah, if it is something like that


I’m not sure at what level of lein you are seeing the problem, but there are ways to give jvm args


for jvm options for your own project, you can add :jvm-opts ["--add-modules" ""]


that may be all you need, if you know what module the java compiler is in that you need


if it more at a leins own jvm process level, then you can look into the JVM_OPTS environment variable or LEIN_JVM_OPTS, I’m not sure the difference offhand, both are referenced in the sample project here

peter hull20:05:02

Thanks. I am at home now but I will try those various options tomorrow at work. I feel I don't really understand java any more...


Well, the Java module system stuff has certainly caused some thrash I’d say


I haven’t done much with Java 9+ yet. I’ll be surprised if you have found a lein config issue with a new jdk that no one else had for some reason.


A lot of lein stuff had issues at first with it trying to load stuff on the bootclasspath and also some dependencies on some now-not-auto-included jdk modules around xml bindings


However, your problem seemed to be a different one with the Java compiler

peter hull20:05:05

Yes, I am sure the problem is more likely to be at my end than something wrong with Fedora or Java or Leiningen. I was hoping someone here would have come across it already and know the answer!

😬 4
peter hull08:05:48

I solved my problem by using the 'alternatives' utility to set the 'java' alternative to Java 10 - it was set to 1.8, even though 'javac' and 'java_sdk_openjdk' were set to Java 10. This seems to have caused confusion.

👍 4

Hah. Well good you tracked it down.

👍 4