Search code examples
javadebianpackagingjhbuild

Force java version in debian packaging


I try to build a debian package of a java application. I've created all needed file. The only problem I have, I think, is to force the java version while using jh_build in the debian/rules

Indeed, here my current file:

#!/usr/bin/make -f

%:
    dh $@ --with javahelper --sourcedirectory=sources

override_jh_build:
    jh_build test.jar sources

I have the following output:

jh_build test.jar sources
warning: [options] bootstrap class path not set in conjunction with -source 7
sources/org/test/preferences/WindowHandler.java:29: error: lambda expressions are not supported in -source 7
        CoalescedEventUpdater updater = new CoalescedEventUpdater(400, () -> updatePref(frame, prefs));
                                                                          ^
  (use -source 8 or higher to enable lambda expressions)
sources/org/test/preferences/CoalescedEventUpdater.java:10: error: lambda expressions are not supported in -source 7
        timer = new Timer(delay, e -> {
                                   ^
  (use -source 8 or higher to enable lambda expressions)
2 errors
1 warning
jh_build: find sources -name '*.java' -and -type f -print0 | xargs -s 512000 -0 /usr/lib/jvm/default-java/bin/javac -g -cp :debian/_jh_build.test -d debian/_jh_build.test -encoding ISO8859-1 -source 1.7 -target 1.7  returned exit code 123

So my question is very simple, where I need to write this option -source 8 ? I tried as a jh_build option with no succes.

EDIT I've tried this line as suggested in comments:

jh_build --javacopts="-source 1.8 -target 1.8" test.jar sources

The output is almost the same, except for the first sentence!!

warning: [options] bootstrap class path not set in conjunction with -source 8
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 warning
sources/org/test/preferences/WindowHandler.java:29: error: lambda expressions are not supported in -source 7
        CoalescedEventUpdater updater = new CoalescedEventUpdater(400, () -> updatePref(frame, prefs));
                                                                          ^
  (use -source 8 or higher to enable lambda expressions)
sources/org/test/preferences/CoalescedEventUpdater.java:10: error: lambda expressions are not supported in -source 7
        timer = new Timer(delay, e -> {
                                   ^
  (use -source 8 or higher to enable lambda expressions)
2 errors

Solution

  • The solution is to define the version for javac and javadoc !!

    jh_build --javacopts="-source 1.8 -target 1.8" --javadoc-opts="-source 1.8" spview.jar sources