Arduino
Arduino copied to clipboard
MacOS - compiles but won't run (error loading Java)
I'm unsure how to resolve this. I've installed JDK8 per the instructions and I can get the thing to compile fine. The app launches but immediately shows an alert "Error loading Java" and quits.
I've checked and rechecked the paths in the output and everything looks fine. As I understand it, the thing bundles the runtime environment into itself so shouldn't be reliant on whatever version of Java the system runs, is that correct?
ant build produces no error.
ant run produces:
BUILD FAILED
/Users/ccarey/Sites/arduino-ide/Arduino/build/build.xml:142: The following error occurred while executing this line:
/Users/ccarey/Sites/arduino-ide/Arduino/build/build.xml:146: The following error occurred while executing this line:
/Users/ccarey/Sites/arduino-ide/Arduino/build/build.xml:543: exec returned: 1
When I run the app directly from its container I get this: ./macosx/work/Arduino.app/Contents/MacOS/Arduino
2020-11-09 10:56:50.141 Arduino[9480:281517] Loading Application 'Arduino'
2020-11-09 10:56:50.142 Arduino[9480:281517] JVMRuntime=adoptopenjdk-8.jdk
2020-11-09 10:56:50.142 Arduino[9480:281517] CFBundleName=Arduino
2020-11-09 10:56:50.142 Arduino[9480:281517] WorkingDirectory=(null)
2020-11-09 10:56:50.142 Arduino[9480:281517] JVMMainClassName=processing.app.Base
2020-11-09 10:56:50.142 Arduino[9480:281517] JVMOptions=(
"-Dapple.awt.application.name=Arduino",
"-Dcom.apple.macos.use-file-dialog-packages=true",
"-Dcom.apple.smallTabs=true",
"-DAPP_DIR=$APP_ROOT/Contents/Java",
"-Djava.ext.dirs=$JVM_RUNTIME/Contents/Home/lib/ext/:$JVM_RUNTIME/Contents/Home/jre/lib/ext/",
"-Djava.net.preferIPv4Stack=true",
"-Xdock:name=Arduino",
"-Dcom.apple.mrj.application.apple.menu.about.name=Arduino",
"-Dfile.encoding=UTF-8",
"-Xms128M",
"-Xmx512M",
"-splash:$APP_ROOT/Contents/Java/lib/splash.png"
)
2020-11-09 10:56:50.142 Arduino[9480:281517] JVMArguments=(
)
2020-11-09 10:56:50.143 Arduino[9480:281517] JVMClasspath=(null)
2020-11-09 10:56:50.143 Arduino[9480:281517] JVMDefaultOptions={
}
2020-11-09 10:56:50.143 Arduino[9480:281517] SearchSystemJVM=false
2020-11-09 10:56:50.143 Arduino[9480:281517] -> Bundle path: /Users/ccarey/Sites/arduino-ide/Arduino/build/macosx/work/Arduino.app
2020-11-09 10:56:50.143 Arduino[9480:281517] -> Working Directory: '/Users/ccarey/Sites/arduino-ide/Arduino/build'
2020-11-09 10:56:50.143 Arduino[9480:281517] -> JVM Runtime path: /Users/ccarey/Sites/arduino-ide/Arduino/build/macosx/work/Arduino.app/Contents/PlugIns/adoptopenjdk-8.jdk
2020-11-09 10:56:50.143 Arduino[9480:281517] -> Java Runtime Dylib Path: '/Users/ccarey/Sites/arduino-ide/Arduino/build/macosx/work/Arduino.app/Contents/PlugIns/adoptopenjdk-8.jdk/Contents/Home/jre/lib/jli/libjli.dylib'
Am I missing something obvious?
I'm having the same issue.
I notice if I run the official executable directly I get a different JVMRuntime string:
Official JVMRuntime=jre8u252-b09.jre
vs
Self-built JVMRuntime=adoptopenjdk-8.jdk
Not sure if that's just an alias and it's actually the same runtime, but I installed java using brew as suggested in the wiki build guide.
$ java -version
openjdk version "1.8.0_272"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_272-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.272-b10, mixed mode)
I'm having the same issue, too. Same symptoms (output) as OP. I'd appreciate any hints as to how to start resolving the issue.
I'm having the same issue myself, anyone crack it yet?
Bumped into this same issue (I think)
ant build leads to an error message saying "Error loading Java."
`start:
macosx-start: [exec] 2021-07-20 22:20:25.248 Arduino[50196:3909729] Loading Application 'Arduino' [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] JVMRuntime=adoptopenjdk-8.jdk [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] CFBundleName=Arduino [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] WorkingDirectory=(null) [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] JVMMainClassName=processing.app.Base [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] JVMOptions=( [exec] "-Dapple.awt.application.name=Arduino", [exec] "-Dcom.apple.macos.use-file-dialog-packages=true", [exec] "-Dcom.apple.smallTabs=true", [exec] "-DAPP_DIR=$APP_ROOT/Contents/Java", [exec] "-Djava.ext.dirs=$JVM_RUNTIME/Contents/Home/lib/ext/:$JVM_RUNTIME/Contents/Home/jre/lib/ext/", [exec] "-Djava.net.preferIPv4Stack=true", [exec] "-Xdock:name=Arduino", [exec] "-Dcom.apple.mrj.application.apple.menu.about.name=Arduino", [exec] "-Dfile.encoding=UTF-8", [exec] "-Xms128M", [exec] "-Xmx512M", [exec] "-splash:$APP_ROOT/Contents/Java/lib/splash.png" [exec] ) [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] JVMArguments=( [exec] ) [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] JVMClasspath=(null) [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] JVMDefaultOptions={ [exec] } [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] SearchSystemJVM=false [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] -> Bundle path: /Users/nklugman/Documents/work/repos/Arduino/build/macosx/work/Arduino.app [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] -> Working Directory: '/Users/nklugman/Documents/work/repos/Arduino/build' [exec] 2021-07-20 22:20:25.249 Arduino[50196:3909729] -> JVM Runtime path: /Users/nklugman/Documents/work/repos/Arduino/build/macosx/work/Arduino.app/Contents/PlugIns/adoptopenjdk-8.jdk [exec] 2021-07-20 22:20:25.250 Arduino[50196:3909729] -> Java Runtime Dylib Path: '/Users/nklugman/Documents/work/repos/Arduino/build/macosx/work/Arduino.app/Contents/PlugIns/adoptopenjdk-8.jdk/Contents/Home/jre/lib/jli/libjli.dylib'`
looking at my Java ->
user@computer build % java -version openjdk version "1.8.0_292" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)
In case someone is having this issue, this is how I managed to solve it (sort of).
I was able to track this error message "Error loading java" to the appbundler native stub (the native binary that starts de JVM): https://github.com/arduino/appbundler/blob/524abf5654e4b564cfe44019fcc048bee6f02b8c/appbundler/native/main.m#L332 Apparently loading the library libjti.dylib was failing for some reason. This native binary is downloaded during the build process (appbundler-1.0ea-arduino9.jar.zip) and unzipped to the work folder, see below.
I wrote a simple program to load the library and get that function address, and it worked, so the library was ok, the stub was the problem.
To help me diagnose the problem, I cloned that repository and added a few more log messages to help me understand what was going on.
But after I build it, and ran 'ant start', the Arduino IDE ran sucessfully. So I dont know exactly what was the issue, but it seems to me that the binary in the build process is having some issue loading that library.
I had to make two changes on the build.xml (on the appbundler repository):
This information may help. I had to change to the sdk version I have installed (11.3), but by the comment in the code, apparently this is not a good solution....
<!-- WARNING: Do NOT use SDK with version superior to 10.9 because side effects have been
reported in applications using OpenGL, in particular AWT based java apps crashing
when using multi-monitor setups. See https://github.com/arduino/Arduino/pull/10234 and
related issues for details. -->
<!--arg value="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk"/-->
<arg value="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk"/>
and removed the code signature (just for the test)
<exec executable="codesign" failonerror="false">
In the Arduino build\build.xml, I removed the target that uses the zip from the internet, and replaced with the jar that I built:
<!--antcall target="unzip">
<param name="archive_file" value="${staging_folder}/appbundler-1.0ea-arduino9.jar.zip" />
<param name="archive_url" value="https://downloads.arduino.cc/appbundler-1.0ea-arduino9.jar.zip" />
<param name="final_folder" value="${staging_folder}/appbundler-1.0ea-arduino9" />
<param name="dest_folder" value="${staging_folder}/appbundler-1.0ea-arduino9" />
</antcall>
<taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="${staging_folder}/appbundler-1.0ea-arduino9/appbundler-1.0ea-arduino9.jar"/-->
<taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="/Users/daniel/appbundler/appbundler/bin/appbundler-1.0.1-arduino.jar"/>
In case you need more details, let me know.
Exactly the same issue. Trying to build Arduino IDE from source code based on this wiki: ant dist, and ant build were successful, but ant start resulted in "error loading java"
My java -version is:
annie@ML-ART-03 build % java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.292-b10, mixed mode)