Java upgrade to 7 / 8

I plan to upgrade to java 7 requirement for the core and java 8 for the web, including upgrades for jetty and json dependencies (web only) and potentially more. java 7 will still work with j2objc and Android but will we have other problems then? Currently we are at java 6 and already java 7 for the android demo.

Java 7 support was added from Android KitKat SDK era:

“Added support for Java 7 language features like multi-catch, try-with-resources, and the diamond operator. These features require version 19 or higher of the Build Tools. Try-with-resources requires minSdkVersion 19; the rest of the new language features require minSdkVersion 8 or higher.”

Note that in demo we have minSdkVersion 10.

Emux

1 Like

Thanks - this means that version 19 is required for building the project but we could still target down to 10 if we avoid try with resources?

That’s right and we already have the latest build tools (>19) in demo.

Also in Mapsforge we keep minSdkVersion 10, not serious reason to advance yet.

Emux

FYI

Android N will introduce support for Java 8 language features.
https://developer.android.com/preview/j8-jack.html

Emux

1 Like

This is now done in the latest master. Please test and report :slight_smile: https://github.com/graphhopper/graphhopper/issues/697

1 Like

I just upgraded to the current master and wondered that we set Java 8 for the web module:

Is there a need to set 1.8 instead of 1.7?

This is a minor issue for me right now, since there is only jdk 7 available on debian (in the official ppa).

Yes, we need 8 for the latest jetty here and also I would like to use the latest Java features in the web module. JDK8 is available on debian based systems via this strange oracle installer

Ok in this case we have to use jdk 8.

I am currently installing jdk8 on my machine. Not really convienient :confused:

I use this tutorial https://wiki.debian.org/JavaPackage but I cannot see an installer. It seems that you have to build a debian pakage from the tar.gz and install that afterwards using dpkg.

@boldtrn if that helps you:

Emux

I’m used to this as this updates also itself but you need to trust the repo owner:

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer

1 Like

@devemux86

Thanks for the link, but I did it as described here: https://wiki.debian.org/JavaPackage

It seems to work for now :slight_smile:.

Here what I documented for my-self. Maybe someone finds it more convenient than the description on the debian page (even though it’s pretty much the same).

# Add a "contrib" component to /etc/apt/sources.list, for example:
e.g. deb http://httpredir.debian.org/debian/ jessie main contrib

apt-get update && apt-get install java-package libgl1-mesa-glx libfontconfig1 libxslt1.1 libxtst6 libxxf86vm1 libgtk2.0-0

cd /tmp/
mkdir jdk
cd jdk/
# Ugly download method... 
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz
cd ..
chmod -R 777 jdk/
su <non-sudo-user>
cd jdk/
make-jpkg jdk-8u77-linux-x64.tar.gz
exit
dpkg -i oracle-java8-jdk_8u77_amd64.deb
# Select JDK 8
update-alternatives --config java 

# check with
java -version
1 Like

Not an expert, but I just found this, Java 8 on Android related:

That is really cool news - thanks! @devemux86 do you know more about this? Could we already switch to Java 8 for the core module (for now just the master branch)? This would make lots of things easier.

We’ll have to see how the default toolchain will support byte code level 52.

And if there would be any version limits on use (e.g. see above for Java 7).

1 Like

Some Java 8 features require API level 24 or higher.

1 Like

Thanks & Ok, this is a bit too high for now (i.e. Android 7.0 and higher). Is it likely they add support for lower versions too?

Let’s hope so. :slight_smile:

1 Like
1 Like

Kotlin would be interesting for us yes. But it is probably a major untertaking to rewrite everything into kotlin, but it would be nice as we would get JS, iOS and first class Android support. We’ll have to discuss & think about it :slight_smile: