Maven install java 6 project

129 Views Asked by At

I have a maven 3.8.4 and java 17 jdk. But I need to install old project where are source and target set to 6 version, because one of my projects uses it as dependency. How can I do that correctly, so later I will be able to use it as dependency in a newer project with source and target >6? My OS is Ubuntu 20.04.

1

There are 1 best solutions below

1
Thorbjørn Ravn Andersen On

I’ve just gone through that exercise on an old repository, including having GitHub Actions compile it. See https://github.com/ravn/jscheme-1998 - note that I decided that it was more important to keep the Java 6 comparability for this particular project than to switch to Java 8 as required by the latest version of slf4j.

Java 17 can read Java 6 byte code, so you may be able to use what you have in jar form already.

If you need to compile and reinstall, Java 8 and 11 can target Java 6 so use that instead of Java 17 for that project.

Easiest way is probably to download an OpenJDK build in zip form, unpack it and prepend the bin folder to your path and unset JAVA_HOME.

That said, upgrading the project to compile with at least Java 8, preferably Java 17 is a good idea. You most likely use libraries that has been found security vulnerabilities in.