简体   繁体   English

使用 Launch4J 将 .java 包装到 .exe 时出现问题,但问题可能是版本合规性

[英]Problem wrapping .java to .exe using Launch4J but problem is likely version compliance

I have a problem trying to wrap a java .jar as .exe and feel like I have checked out all there was on here which was remotely related.我在尝试将 java .jar包装为.exe遇到问题,并且感觉我已经检查了此处所有与远程相关的内容。 But I still couldn't get it to work.但我仍然无法让它工作。 All the questions I found which seemed similar only concerned a part of my problem and also, the solution didn't work for me (such as this Convert .jar to .exe using launch4j or this The compiler compliance specified is 1.6 but a JRE 1.8 is used and many more).我发现的所有看似相似的问题都只涉及我的问题的一部分,而且该解决方案对我不起作用(例如使用 launch4j 将 .jar 转换为 .exe或此指定的编译器合规性为 1.6 但 JRE 1.8使用等等)。

The Problem问题

So, in my concrete case, I need to wrap a small program to a Windows .exe for an elderly person to use (I can't expect them to run a .jar file themselves).因此,在我的具体案例中,我需要将一个小程序包装到 Windows .exe以供老年人使用(我不能指望他们自己运行.jar文件)。 I'm trying to get everything to run on 1.0.8, so that's Java 8. The errors I get are, on the one hand, that the resulting .exe doesn't work, throwing a class error (indicating that there's a problem with the compiler compliance) when trying to run it.我试图让一切都在 1.0.8 上运行,所以这就是 Java 8。一方面,我得到的错误是生成的.exe不起作用,抛出类错误(表明存在问题)与编译器合规性)尝试运行时。 Later on, trying around, I also got a compiler compliance warning in Eclipse, so that's likely the problem.后来,尝试了一下,我还在 Eclipse 中收到了编译器合规性警告,所以这可能是问题所在。

Then I also get an error concerning module-info.java .然后我也收到一个关于module-info.java的错误。 Just deleting the contents of the file seems to help (in terms of Eclipse warnings) but the final result also doesn't work.只是删除文件的内容似乎有帮助(就 Eclipse 警告而言),但最终结果也不起作用。 I saw that you need Java 9 to use module-info.java .我看到您需要 Java 9 才能使用module-info.java What do I have to do with this?这与我有什么关系? I couldn't find any helpful answers on here (or maybe I didn't understand them).我在这里找不到任何有用的答案(或者我可能不理解它们)。

What I've tried我试过的

I have both the JDK and JRE installed (enviroment var set to JRE).我安装了 JDK 和 JRE(环境变量设置为 JRE)。 I tried a clean and rebuild (like suggested in a question I can't find anymore) but it didn't do anything.我尝试了清理和重建(就像我找不到的问题中所建议的那样),但它没有做任何事情。

I am not so famililar with Java and usually use Linux, so Windows problems are not so familiar to me.我对Java不太熟悉,平时用的是Linux,所以Windows的问题对我来说不是那么熟悉。 I have found myself a Windows machine to compile my program from (because there seem to have been Java version problems when using Launch4J under Linux, trying to get an .exe .)我找到了一台 Windows 机器来编译我的程序(因为在 Linux 下使用Launch4J时似乎存在 Java 版本问题,试图获取.exe 。)

Edit: If one of you can help me solve my problem under Linux, that would be my favourite kind of solution.编辑:如果你们中的一个能帮我解决 Linux 下的问题,那将是我最喜欢的一种解决方案。 I currently use Linux Mint 20 but I also have Ubuntu installed on a machine I can access.我目前使用 Linux Mint 20,但我也在可以访问的机器上安装了 Ubuntu。

In the end, I think my Launch4J problem is actually a pre-existing problem of my .jar file stemming from the errors outlined above which I'll sum up again below:最后,我认为我的Launch4J问题实际上是我的.jar文件的一个预先存在的问题,源于上面概述的错误,我将在下面再次总结:

I have been trying around for ages but I always get我已经尝试了很长时间,但我总是得到

  1. The warning: The compiler compliance specified is 1.8 but a JRE 14 is used警告: The compiler compliance specified is 1.8 but a JRE 14 is used
  2. The error: Syntax error on token "module", interface expected错误: Syntax error on token "module", interface expected

I think that I should have fixed the compliance (both in Build Path and Compiler in the Properties) but it still doesn't work and it seems I've tried all there is.我认为我应该修复合规性(在“属性”中的“ Build Path和“ Compiler中),但它仍然不起作用,看来我已经尝试了所有方法。 The environment variable is set and all.环境变量已经设置好了。 (There also isn't a javac.exe in my folder in case that makes a difference? Someone said to download it again but it doesn't help. Also, I've tried it on the customer's computer. They had a javac.exe and the whole thing still didn't work altough throwing different errors.) (我的文件夹中也没有javac.exe以防万一?有人说重新下载它,但没有帮助。另外,我已经在客户的计算机上试过了。他们有一个javac.exe和整个事情仍然没有工作,尽管抛出了不同的错误。)

Contents of module-info.java module-info.java内容

Regarding the module, as the asker of this question ( "Syntax error on token "module", interface expected" ) has nothing but关于模块,作为这个问题的提问者( “令牌“模块”上的语法错误,预期接口” )只有

module NameOfMyThingy {
}

Maybe some of you can help - would appreciate it!也许你们中的一些人可以提供帮助 - 将不胜感激! Thanks!谢谢!

Rather than using launch4j, I recommend that you take a look at jpackage, which is available in JDK 14 and 15. See Packaging Tool User's Guide .我建议您查看 jpackage,而不是使用 launch4j,它在 JDK 14 和 15 中可用。请参阅Packaging Tool User's Guide Note that for Windows you will also need to download the WiX toolset .请注意,对于 Windows,您还需要下载WiX 工具集

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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