Modify

Opened 5 years ago

Closed 4 years ago

#18319 closed defect (fixed)

Can't launch JOSM.app on macOS with OpenJDK installed, instead of JRE from Oracle.

Reported by: molind Owned by: Stereo
Priority: normal Milestone:
Component: Installer MacOS Version:
Keywords: macos Cc: simon04

Description

I'm using OpenJDK during my work and keep it as only available java on my macOS. It's installed using 'brew cask install java'. After that java is available in Terminal:

evgen@Evgens-iMac Java % java --version
openjdk 13.0.1 2019-10-15
OpenJDK Runtime Environment (build 13.0.1+9)
OpenJDK 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)

I could launch: java --jar josm-snapshot-15492.jar using snapshot bundled inside JOSM.app, but when I'm trying to launch JOSM.app itself it shows an error: JRE load error as window. When i launch it from termital i see following:

evgen@Evgens-iMac MacOS % ./JOSM
2019-11-13 11:19:00.704 JOSM[84913:5495924] NSString *findJavaDylib(NSString *, _Bool, _Bool, _Bool, _Bool) Searching for a JRE.
2019-11-13 11:19:00.705 JOSM[84913:5495924] NSString *findJREDylib(int, _Bool, _Bool) JRE search exception: 'launch path not accessible'
2019-11-13 11:19:00.773 JOSM[84913:5495924] NSString *findJavaDylib(NSString *, _Bool, _Bool, _Bool, _Bool) No matching JRE or JDK found.
2019-11-13 11:19:00.773 JOSM[84913:5495924] int launch(char *, int, char **) Launchpath: (null)
2019-11-13 11:19:00.775 JOSM[84913:5495924] int launch(char *, int, char **) Error launching JVM Runtime ((null)) Relative Path: '(null)' (dylib: (null))
  error: JRELoadError

Attachments (4)

appbundler.jar (161.3 KB ) - added by molind 5 years ago.
josm-macos-icons.zip (1.1 MB ) - added by Stereo 4 years ago.
JOSM icons for macOS, created with docerator.py --appicon /Applications/JOSM.app/Contents/Resources/JOSM.icns --text OSM etc.
JOSM.icns (207.8 KB ) - added by Stereo 4 years ago.
Optimised JOSM.icns for macOS: crushed PNG, removed unnecessary sizes
jpackage-properties.zip (4.8 KB ) - added by Stereo 4 years ago.
.properties file to be used for packaging

Download all attachments as: .zip

Change History (51)

comment:1 by anonymous, 5 years ago

Seems an additional option required for <bundleapp> in build.xml to correctly detect JRE in runtime.

comment:2 by Don-vip, 5 years ago

Component: CoreInstaller MacOS

comment:3 by Don-vip, 5 years ago

Probably a side effect of the issues listed there: https://github.com/teras/appbundler/issues

If you're a Java developer working on Mac, maybe you know what needs to be fixed? I have too little knowledge of how macOS works to fix this issue right now.

Note that OpenJDK is working on a new tool in Java 14 to package applications: https://openjdk.java.net/jeps/343

Last edited 5 years ago by Don-vip (previous) (diff)

comment:4 by molind, 5 years ago

I've used appbundler from https://github.com/TheInfiniteKind/appbundler/ instead of provided in tools folder and it worked.

It worked without issues on my machine with OpenJDK 13.0.1 but it worked with multiple exceptions when my colleague launched on machine with Java 1.8 1.8.0_181-b13. I think it's because of JRE version mismatch. When old version of JRE used to run code from newer JRE.

Maybe JOSM.app should include JRE used to build the app?

in reply to:  4 ; comment:5 by Don-vip, 5 years ago

Replying to molind@…:

I've used appbundler from https://github.com/TheInfiniteKind/appbundler/ instead of provided in tools folder and it worked.

Where is the binary? I don't see any release on this repo.

It worked without issues on my machine with OpenJDK 13.0.1 but it worked with multiple exceptions when my colleague launched on machine with Java 1.8 1.8.0_181-b13. I think it's because of JRE version mismatch. When old version of JRE used to run code from newer JRE.

Can you please report the issues to the author? If we switch to it still must be compatible with java 8.

Maybe JOSM.app should include JRE used to build the app?

It shouldn't be necessary.

in reply to:  5 comment:6 by anonymous, 5 years ago

Replying to Don-vip:

Replying to molind@…:

I've used appbundler from https://github.com/TheInfiniteKind/appbundler/ instead of provided in tools folder and it worked.

Where is the binary? I don't see any release on this repo.

I just built it using ant.

It worked without issues on my machine with OpenJDK 13.0.1 but it worked with multiple exceptions when my colleague launched on machine with Java 1.8 1.8.0_181-b13. I think it's because of JRE version mismatch. When old version of JRE used to run code from newer JRE.

Can you please report the issues to the author? If we switch to it still must be compatible with java 8.

Just to be clear. It wasn't appbundler issue, but JOSM issue.

Maybe JOSM.app should include JRE used to build the app?

It shouldn't be necessary.

Okay. I'll submit crashes right away. And post links right there.

Last edited 5 years ago by molind (previous) (diff)

by molind, 5 years ago

Attachment: appbundler.jar added

comment:8 by Stereo, 5 years ago

The advantages of switching to OpenJDK on Retina displays are so considerable (see #18720) that I think it would make sense to jump to supporting only OpenJDK, and closing this ticket with the proposed fix despite all of the flaws it currently has.

A temporary workaround is to launch josm from the command line, java -jar /Applications/JOSM.app/Contents/Java/josm-*.jar

in reply to:  8 comment:9 by Don-vip, 5 years ago

Replying to Stereo:

The advantages of switching to OpenJDK on Retina displays are so considerable (see #18720)

Beware, the improvements you see are due to your switch from Java 8 to Java 13, which contains a lot of HIDPI improvements. You would have seen the same improvements with an Oracle runtime. They are 99.99% identical.

It doesn't mean however we will continue to support Oracle runtime. At the end of the year, the Java 8 Oracle binaries will no longer be provided to Windows and mac users. See #17858 for the switch to OpenWebStart/AdoptOpenJDK/Java 11.

comment:10 by Stereo, 5 years ago

Aha! I'll brew install oracle-jdk in the meanwhile then.

comment:11 by Stereo, 5 years ago

All right, it turns out there's no Oracle JRE beyond Java 8 for macOS, as far as I can tell. Installing just the Oracle 13 JDK produces the same JRELoadError.

It seems like the best path would be for JOSM to support launching from a preinstalled openjdk 13 bundle, or indeed to bundle its own JRE.

comment:12 by Stereo, 5 years ago

The freshly released Java 14 now has a nice new bundler.

comment:13 by anonymous, 5 years ago

Sounds great! Do you need any assistance to try it on macOS?

comment:14 by molind, 5 years ago

Last message was mine. Let me know if I could help to check it on macOS Catalina.

in reply to:  description comment:15 by ryandesign, 5 years ago

JOSM was just submitted to MacPorts and I approved the submission even though the problem reported in this ticket also happened to me during testing. On my system:

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.13.6
BuildVersion:	17G12034
$ java --version
openjdk 12.0.2 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 12.0.2+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 12.0.2+10, mixed mode, sharing)
$ /Users/rschmidt/Downloads/josm-macosx/JOSM.app/Contents/MacOS/JOSM ; exit;
2020-05-08 00:21:15.283 JOSM[19765:14464724] NSString *findJavaDylib(NSString *, _Bool, _Bool, _Bool, _Bool) Searching for a JRE.
2020-05-08 00:21:15.284 JOSM[19765:14464724] NSString *findJREDylib(int, _Bool, _Bool) JRE search exception: 'launch path not accessible'
2020-05-08 00:21:15.353 JOSM[19765:14464724] NSString *findJDKDylib(int, _Bool, _Bool) JDK search exception: '*** -[__NSCFString substringFromIndex:]: Index 9223372036854775811 out of bounds; string length 58'
2020-05-08 00:21:15.353 JOSM[19765:14464724] NSString *findJavaDylib(NSString *, _Bool, _Bool, _Bool, _Bool) No matching JRE or JDK found.
2020-05-08 00:21:15.353 JOSM[19765:14464724] int launch(char *, int, char **) Launchpath: (null)
2020-05-08 00:21:15.356 JOSM[19765:14464724] int launch(char *, int, char **) Error launching JVM Runtime ((null)) Relative Path: '(null)' (dylib: (null))
  error: JRELoadError

Hopefully you can solve this problem and release a new version so that we can update to that in MacPorts so that our users won't experience this issue.

comment:16 by dr.snaglers@…, 4 years ago

I've resolved the issue by using brew and OpenJDK 11.

brew cask install josm
brew cask install java11

OSM Jar downloaded by brew : josm-snapshot-16239.jar

java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
Last edited 4 years ago by simon04 (previous) (diff)

comment:17 by Stereo, 4 years ago

I'm not sure what your setup is or if you have an extra homebrew tap? Here's what I'm getting:

> brew cask install java11
Error: Cask 'java11' is unavailable: No Cask with this name exists.

Did you mean brew install java11?

Last edited 4 years ago by Stereo (previous) (diff)

comment:18 by Stereo, 4 years ago

I'm still getting JRELoadError with the java11 formula installed. You might still have Oracle Java installed - what does the JOSM about window say?

comment:19 by anonymous, 4 years ago

Hello,

I'm not sure, if I've added another cask in the past. How do I find out?

However, I'm certain I've installed the JRE with following command:

brew cask install java11

And

brew cask info java11 says:
java11: 11.0.2,9
https://www.oracle.com/technetwork/java/javase/
/usr/local/Caskroom/java11/11.0.2,9 (148B)
From: https://github.com/Homebrew/homebrew-cask-versions/blob/master/Casks/java11.rb
==> Name
OpenJDK Java Development Kit
==> Artifacts
jdk-11.0.2.jdk -> /Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk (Generic Artifact)

Furthermore, JOSM About says I'm using following Java Home:
/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home

Anyway, the solution is to not use last Java version (14). That's what JOSM says, it isn't compatible. In general, it's more save to go with Java 11, since it's long term support version, therefore, supported by most applications.

comment:20 by anonymous, 4 years ago

Hi again,
I've found from where I've installed this version of JRE.

It's from homebrew/cask-versions

Therefore, the complete installation instruction would be:

brew tap homebrew/cask-versions
brew cask install java11
brew cask install josm

For more information see : https://github.com/Homebrew/homebrew-cask-versions

Have fun!

comment:21 by Stereo, 4 years ago

All right, that explains it. That java11 cask installs https://download.oracle.com/java/GA/jdk11/9/GPL/openjdk-11.0.2_osx-x64_bin.tar.gz so not openjdk but oracle.

It's a valuable workaround, but not a fix.

comment:22 by Stereo, 4 years ago

I've played with jpackage a bit, and it looks quite promising. I have a JOSM.app that includes the OpenJDK 14 JRE and runs quite well.

I've used /Library/Java/JavaVirtualMachines/openjdk-14.0.1.jdk/Contents/Home/bin/jpackage -n "JOSM" --input dist --main-jar josm-custom.jar --main-class org.openstreetmap.josm.gui.MainApplication --icon ./native/macosx/JOSM.icns --type app-image --dest appimageoutput --java-options "-Xmx8192m" --app-version "16539" --copyright "JOSM, and all its integral parts, are released under the GNU General Public License v2 or later" --vendor "https://josm.openstreetmap.de" --file-associations native/macosx/bz2.properties --file-associations native/macosx/geojson.properties --file-associations native/macosx/gpx.properties --file-associations native/macosx/gz.properties --file-associations native/macosx/jos.properties --file-associations native/macosx/joz.properties --file-associations native/macosx/osm.properties --file-associations native/macosx/zip.properties --add-modules java.base,java.datatransfer,java.desktop,java.logging,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.sql,java.transaction.xa,java.xml,jdk.crypto.ec,jdk.jfr,jdk.jsobject,jdk.unsupported,jdk.unsupported.desktop,jdk.xml.dom

The properties files basically look like:

extension=osm
mime-type=application/x-osm+xml
icon=native/macosx/JOSM.app/Contents/Resources/JOSM.icns
description=JOSM File

What doesn't work yet:

  • Done: I only tell it that it can open .osm and .gpx files, basically out of laziness. Every file type needs a .properties file.
  • Done: There are no icons for the gpx and osm files. Giving it the path to JOSM.icns in the .properties file causes an error ("java.nio.file.FileAlreadyExistsException: appimageoutput/JOSM.app/Contents/Resources/JOSM.icns") and a blank icon for JOSM.app. Hey, maybe I can finally create icons for .osm files on macOS :)
  • Done and shrunk to 36.9M zipped: It includes *all* of the JRE, so the .app is a humongous 147MB. [jlink can be used to produce a jre with only the necessary parts](https://www.baeldung.com/jlink). Not including a JRE is, apparently, not possible. Considering how much of a pain it is to install Java and to debug different JREs, this might actually be a good thing
  • Building only works on macOS, and the JOSM builds are currently only built on Linux.
  • Done thanks to Thomas Skowron's help: No code signature yet. Opening the app will say that is is damaged. Run xattr -d com.apple.quarantine JOSM.app.

Wanna test? https://openstreetmap.lu/JOSM.zip has this very raw first preview.

Last edited 4 years ago by Stereo (previous) (diff)

by Stereo, 4 years ago

Attachment: josm-macos-icons.zip added

JOSM icons for macOS, created with docerator.py --appicon /Applications/JOSM.app/Contents/Resources/JOSM.icns --text OSM etc.

comment:23 by Stereo, 4 years ago

It looks like macOS auto-generates good enough document images if we let it, so let's scratch that :)

by Stereo, 4 years ago

Attachment: JOSM.icns added

Optimised JOSM.icns for macOS: crushed PNG, removed unnecessary sizes

by Stereo, 4 years ago

Attachment: jpackage-properties.zip added

.properties file to be used for packaging

comment:24 by Stereo, 4 years ago

So it looks like all the known issues are taken care of. We'll always need macOS to run for signing, but something like GitHub Actions could do that on every commit.

https://openstreetmap.lu/JOSM.zip is the latest test build. Please try it out and let me know.

in reply to:  24 ; comment:25 by simon04, 4 years ago

Replying to Stereo:

We'll always need macOS to run for signing, but something like GitHub Actions could do that on every commit.

Currently, we're already using 3 different CI systems:

Can anyone of those be configured for this purpose?

in reply to:  25 comment:26 by Don-vip, 4 years ago

Replying to simon04:

I guess we should transfer this one to JOSM organization and start to use it for producing such native apps.

comment:28 by Stereo, 4 years ago

We don't seem to be using Travis for anything other than ant tests:

https://github.com/openstreetmap/josm/blob/master/.travis.yml

I'd be just as happy to rewrite those in github actions.

comment:29 by Stereo, 4 years ago

Cc: simon04 added
Owner: changed from team to Stereo

Rewritten Travis ant tests as GitHub Actions:

https://github.com/grischard/josm/blob/master/.github/workflows/ant.yml

Preliminary results are here: https://github.com/grischard/josm/runs/757124064?check_suite_focus=true

It fails on creating a RELEASE.xml which is the same as https://lists.openstreetmap.org/pipermail/josm-dev/2014-February/006898.html but I'm not sure how to fix it. Maybe simon04 has an idea?

comment:30 by simon04, 4 years ago

Six years have passed since I wrote this part in the build file, see r6545. Maybe you can execute the command separately to see if it is working. Some time ago, I tested the following build based on a sparse checkout: ticket:6887#comment:51

comment:31 by simon04, 4 years ago

The problem is that GitHub Actions fetches the repository using --depth=1. Since the latest commit is a non-git-svn commit, no SVN revision can be obtained:

$ git init
$ git remote add origin https://github.com/grischard/josm
$ git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin
$ git log origin/master 
commit 13739d01139edfcd0b5adb69fb811a490ce837a8 (grafted, origin/master)
Author: Guillaume Rischard <github@stereo.lu>
Date:   2020-06-10 10:48:51 +0200

    Say the same thing but more simply
<only one commit>
$ git log origin/master -1 --grep=git-svn-id 
<nothing>

You may want to increase the fetch-depth as documented on https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches
Maybe fetch-depth: 32 is sufficient, assuming that there are no more than 32 commits after the latest git-svn commit.

comment:32 by Stereo, 4 years ago

(Discussion about ant tests is now taking place in #19370)

Last edited 4 years ago by Stereo (previous) (diff)

comment:33 by Stereo, 4 years ago

The Github Actions now builds, packages and uploads a JOSM.app.

comment:34 by Stereo, 4 years ago

Keywords: macos added

comment:35 by simon04, 4 years ago

In 16776/josm:

see #19370, see #18319 - Enable GitHub Actions and package for macOS (patch by Stereo and thomersch)

comment:36 by simon04, 4 years ago

In 16785/josm:

see #19370, see #18319 - native/macosx/JOSM.app/Contents/Resources/JOSM.icns (used by Ant)

comment:37 by simon04, 4 years ago

In 16786/josm:

see #19370, see #18319 - native/macosx/JOSM.app/Contents/Info.plist_template.xml (used by Ant)

comment:38 by Robert Floor , 4 years ago

Hi all, I am still seeing the JRELoadError in josm-macosx-16812. Should it be solved or should I wait? Kind regards,

Robert Floor

comment:39 by Stereo, 4 years ago

Hi Robert,

For now you can grab a working Java 14 build from https://github.com/thomersch/josm/suites/1032124261/artifacts/13674747

No Java installation required; it comes with batteries included.

comment:40 by Robert Floor, 4 years ago

Thank you very much for the file, Would it also be possible to include javaFX in the build for the mapillary plugin ?

comment:41 by Stereo, 4 years ago

Unfortunately, javafx isn't supported by the java packaging tools we use. For now, you can disable it for mapillary in the preferences - it affects the date/time chooser.

comment:42 by anderfo, 4 years ago

Still an issue in macOS Catalina 10.15.6 (19G2021) and josm-macosx-17013.
Stereo's link above to https://github.com/thomersch/josm/suites/1032124261/artifacts/13674747 is dead.

What's the recommended solution at the moment?

comment:43 by Stereo, 4 years ago

There will "usually" be a recent build up at https://github.com/thomersch/josm/actions. If you click on the top "Java CI" item, there'll be "JOSM.app revision 17015" in the Artifact section.

When I have time, I'll set up a proper way of doing releases.

in reply to:  39 comment:44 by anonymous, 4 years ago

Replying to Stereo:

Hi Robert,

For now you can grab a working Java 14 build from https://github.com/thomersch/josm/suites/1032124261/artifacts/13674747

No Java installation required; it comes with batteries included.

That link is useless

comment:45 by Stereo, 4 years ago

Those links expired after a while.

You can try the new pre-releases at https://github.com/thomersch/josm/releases

comment:46 by Stereo, 4 years ago

Status: newassigned

comment:47 by Stereo, 4 years ago

Resolution: fixed
Status: assignedclosed

The new builds at https://github.com/openstreetmap/josm/releases work with a built-in Java 15 OpenJDK JRE. The next 'tested' release will use those.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Stereo.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.