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

329 views Asked by At

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. 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).

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). 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. Later on, trying around, I also got a compiler compliance warning in Eclipse, so that's likely the problem.

Then I also get an error concerning 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. I saw that you need Java 9 to use 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). 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. 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.)

Edit: If one of you can help me solve my problem under Linux, that would be my favourite kind of solution. I currently use Linux Mint 20 but I also have Ubuntu installed on a machine I can access.

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:

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
  2. The error: 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. 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.)

Contents of 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!

1

There are 1 answers

0
John Moore On

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. Note that for Windows you will also need to download the WiX toolset.