JOSM on macOS: how to set Java version?

Hi! I’m installing JOSM on several computers, looking for reproducibility of a failure while executing FIT plugin (JOSM crashes while opening a fit file).

FIT plugin requires Java 21. I successfully update my Windows and Ubuntu boxes to use that Java release. And also macOS to Java 22:

Last login: Thu Apr 11 13:56:21 on console
ricardorodriguez@igfae5s-MacBook-Air ~ % java -version
java version "22" 2024-03-19
Java(TM) SE Runtime Environment (build 22+36-2370)
Java HotSpot(TM) 64-Bit Server VM (build 22+36-2370, mixed mode, sharing)
ricardorodriguez@igfae5s-MacBook-Air ~ % 

But when launching JOSM on macOS, it keeps claiming that Java 17 is installed and I must update:

In Preferences, I only find in variable related with Java that reads 17.0.10:

Please, how can I configure JOSM on macOS to work with the Java release, installed on the system? Also, I’m not able to find where 17.0.10 is installed. I only find jdk-22:

ricardorodriguez@igfae5s-MacBook-Air ~ % sudo mdfind -name 'java' | grep '/bin/java$'
Password:
2024-04-11 14:57:27.674 mdfind[1215:29865] [UserQueryParser] Loading keywords and predicates for locale "en_US"
2024-04-11 14:57:27.675 mdfind[1215:29865] [UserQueryParser] Loading keywords and predicates for locale "en"
/Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home/bin/java
ricardorodriguez@igfae5s-MacBook-Air ~ % 

Thanks for your help!

OK. It looks like the homebrew cask is using the Java 17 package instead of the Java 21 package.

I’m going to guess that you used brew to install JOSM. I’ll open a PR to fix that in homebrew.

EDIT: PR for homebrew: josm: Use Java 21 package by tsmock · Pull Request #171165 · Homebrew/homebrew-cask · GitHub

It should be available now.
With that said, since the version number did not change, you may need to reinstall it. Example:

$ brew upgrade && brew uninstall josm && brew install josm

If that doesn’t work, brew is probably trying to use the cached file. In which case, this should work:

$ brew upgrade && brew uninstall josm && brew cleanup -s josm && brew install josm
  • You are probably running JOSM from the macOS app.
  • The macOS app was including Java 17 as a bundled dependency up until a month ago or so.

Solutions:

  1. Use the JNLP and OpenWebstart
  2. Use the jar and system java (not recommended; there are some CLI arguments that you need to add to avoid crashes in certain situations)
  3. Update the JOSM app

Yes! It is correct! Thanks for your answer.

Before trying option 1 as it will cause to me some headaches with other applications, I would like to understand why an update JOSM is not working. I updated recently and get same results:

Any idea, please?

It is also correct. Thanks! I now understand better JOSM functioning on macOS when installed as homebrew-cask.

When must I expect to be able to get an updated JOSM cask once your PR has been already verified, please? I’m still far from understanding the homebrew-casks release cycle.

Thank you very much!