在 debian 打包中强制使用 java 版本



我尝试构建一个 java 应用程序的 debian 包。 我已经创建了所有需要的文件。我认为,我唯一的问题是在 debian/rules 中使用 jh_build 时强制使用 java 版本

确实,这是我当前的文件:

#!/usr/bin/make -f
%:
dh $@ --with javahelper --sourcedirectory=sources
override_jh_build:
jh_build test.jar sources

我有以下输出:

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

所以我的问题很简单,我需要在哪里写这个选项 -source 8 ? 我尝试作为一个jh_build选项,但没有成功。

编辑我已经按照评论中的建议尝试了这一行:

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

输出几乎相同,除了第一句!!

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

默认版本是Java 7,您可以在日志-source 1.7的最后一行中看到。

您需要将所需的版本传递给您的jh_build,如下所示:

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

注意:这听起来可能很明显,但您需要 JDK 8 或更高版本。

解决方案是定义javac和javadoc的版本!

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

最新更新