java - 在 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 或更高版本。
推荐阅读
- java - 提取特定规则或标记之前的隐藏评论内容(Antlr、Java)
- java - 如何在微调器中隐藏项目的 id?
- azure - 什么是 Microsoft.VisualStudio.Azure.Containers.Tools.Targets 包?
- r - 如何测试r中的均值和方差之间的差异?
- expect - 重置期望的超时计时器,同时从发送命令接收输出
- java - SurfaceView 作为背景
- mongodb - MongoDB 2.6 在 Amazon ECS 中突然停止(收到信号 15(已终止),将在当前 cmd 结束后终止)
- prolog - 从元组列表中的元组中获取每隔一个项目
- dart - 如何为包装在 Listview 中的容器提供 onTap 功能
- itext - 块和颜色类需要哪个包