0

I have built a Java SWT application using Eclipse on a Windows 10 (64 bit) laptop. I am trying to convert it into a .exe file so anyone can run the application regardless of having java installed.

I have used Launch4J to convert my runnable .jar file to a .exe file and I am successfully able to run it on my laptop.

However, when I try to run it on any other laptop, the .exe file does not open/does nothing on a double click.

When I tried to run the original .jar file on a different laptop from command line this is the error I am getting: Jar file error

_ Other posts on here say to include JRE and libraries in the build path which I did but it did not fix the problem. Java Build Path

Does anyone know how to fix this and allow my application to run?

aight101
  • 63
  • 6
  • Exactly as the error says, you need to compile your code for an older version of Java, or you need to make sure that the other PC's have the correct version or java (or newer) to match what your code was compiled against. Depending on the application, many of us still compile with older versions Java 8 to ensure compatibility. One solution when it comes to an exe file is that Launch4J has the option to package the jre/JVM inside your EXE file which means you can guarantee the version being used, although it creates a much larger exe given that it now contains all of the JVM/jre files. – sorifiend Nov 10 '21 at 03:49
  • Note: Java version 52=Java 8, whereas java version 55=Java 11. It looks like your eclipse widget library requires the newer version, so you'll need to install Java 11 on that PC to run your jar (or package it into the exe), or you'll need to find an older version of the eclipse library that has been compiled for java 8 that you can use in your project. – sorifiend Nov 10 '21 at 03:54
  • @sorifiend I was successfully able to run my .exe file by adding in the necessary jre libraries, thank you! if you add this as an answer, i will accept it as the solution. – aight101 Nov 10 '21 at 23:26
  • Excellent to hear you resolved the issue. Let's close this question as a duplicate of this other one [How to bundle a JRE with Launch4j?](https://stackoverflow.com/questions/7071133/how-to-bundle-a-jre-with-launch4j) which has some excellent answers. – sorifiend Nov 10 '21 at 23:51

1 Answers1

1

The message means the SWT code has been compiled with Java 11 (class file version 55) but you are trying to run it with Java 8 (class file version 52).

You can't do this, you need at least Java 11 to run current versions of SWT (or any Eclipse code).

If you must run with Java 8 the SWT for Eclipse 2020-06 (4.16) was the last to be compiled for Java 8. The archive site here has that build.

greg-449
  • 109,219
  • 232
  • 102
  • 145