Arduino on Linux with Java 9 internal bug - fix

Aus Markus' Wiki
Wechseln zu: Navigation, Suche

1 Problem description

The Arduino GUI refuses to start.

I have hit the following bug:

Exception in thread "main" java.lang.ExceptionInInitializerError
at processing.app.Preferences.save(Preferences.java:735)
at processing.app.Preferences.init(Preferences.java:249)
at processing.app.Base.main(Base.java:117)
Caused by: java.lang.NumberFormatException: For input string: "9-i"
at jdk.internal.math.FloatingDecimal.readJavaFormatString(java.base@9-internal/FloatingDecimal.java:2054)
at jdk.internal.math.FloatingDecimal.parseFloat(java.base@9-internal/FloatingDecimal.java:122)
at java.lang.Float.parseFloat(java.base@9-internal/Float.java:451)
at java.lang.Float.<init>(java.base@9-internal/Float.java:532)
at processing.core.PApplet.<clinit>(Unknown Source)

2 Solution

Here is a good description of the error:

https://askubuntu.com/questions/832486/errors-when-trying-to-run-arduino

Fix:

Downloading the Java 8u152 JDK from Oracle. Removal of OpenJDK Java 9 from my system and replacing it by Oracle's Java 8u152 version.

The bug is due to a parsing error of the version string. Replacing the "9-internal" version by a regularly numbered Java version will help. I chose to use the 8u152 version from Oracle.

In order to keep up Debian / Ubuntu package management, I decided to build a deb package, following the following solution proposal:

https://wiki.debian.org/JavaPackage

2.1 Process

Add a "contrib" component to /etc/apt/sources.list, for example:

Debian 8 "Jessie"

deb http://httpredir.debian.org/debian/ jessie main contrib

Update the list of available packages and install the java-package package:

apt-get update && apt-get install java-package && exit

Download the desired Java JDK/JRE binary distribution (Oracle). Choose tar.gz archives or self-extracting archives, do not choose the RPM!

Use java-package to create a Debian package, for example:

make-jpkg jdk-8u51-linux-x64.tar.gz

Install the binary package created:

su
dpkg -i oracle-java8-jdk_8u51_amd64.deb

2.2 Configuration

By default the DebianAlternatives will automatically install the best version of Java as the default version. If the symlinks have been manually set they will be preserved by the tools. The update-alternatives tools try hard to respect explicit configuration from the local admin. Local manual symlinks appear to be an explicit configuration. In order to reset the alternative symlinks to their default value use the --auto option.

update-alternatives --auto java

If you'd like to override the default to perhaps use a specific version then use --config and manually select the desired version.

update-alternatives --display java
update-alternatives --config java 

Choose the appropriate number for the desired alternative.

The appropriate java binary will automatically be in PATH by virtue of the /usr/bin/java alternative symlink.

You may also use the update-alternatives tool from java-common package which lets you update all alternatives belonging to one runtime/development kit at a time. Steps to do so:

List the Java alternatives presently installed and available on your system

sudo update-java-alternatives -l

Set the default Java and update all alternatives

sudo update-java-alternatives -s <alternative>

Notes

Where <alternative> is the default Java. For example java-1.8.0-openjdk-amd64 or jdk-8-oracle-x64 This command will register all the java executables. And create symlinks for each of them.

If Terminal return any of the following errors, ignore them. Because ?IceaTea 8 isn't ready yet and those errors are about browser plugin only.

error: no alternatives for mozilla-javaplugin.so

plugin alternative does not exist: /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so