简体   繁体   中英

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

The default version is Java 7 as you can see in the last line of your log -source 1.7 .

You need to pass the needed version to your jh_build like following:

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

NOTE: It might sound obvious but you need JDK 8 or higher.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM