Problem
I created a Java project in Eclipse and intended to make an exe file that takes a xlsx file and a text file next to it. Is it possible?
Here's the directory structure of my project:
.
|-.settings
|- bin
|- src
| |- MyApp.java
| |- input.xlsx
| |- key.txt
|
|- .classpath
|- .project
I also added external jar files such as Apache POI from my IDE (Eclipse). It runs with no errors in the IDE.
Desired Outcome
I want to create a exe file as follows:
.
|- MyApp.exe
|- input.xlsx
|- key.txt
|- log
| |- error-mmddyyyy.txt
So when MyApp.exe
is executed, it will take input.xlsx
and key.txt
as its input, and generate output in log
directory. And I can send this exe file to someone else. If they structure the files correctly, the program will have correct input, and generate correct output. They don't need to install Java or anything else.
I wanted to know if this was achievable.
Solution Attempted
Launch4j
I have tried exporting the project into a runnable jar file, and I am able to run the file using java -jar MyApp.jar
. I tried using Launch4j but I failed because of some version issues:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Test has been compiled
by a more recent version of the Java Runtime (class file version 61.0), this version of
the Java Runtime only recognizes class file versions up to 52.0
I tried to recompiled my program to Java 8 but it made my program not recognize the jar files I added.
jpackage
I also attempted to use jpackage
to create an installer for Windows, but the outcome was not what I was looking for. This created an exe to "install" a program to the system. I only wanted an exe file to do what I programmed in the java project.
Thank you in advance for whoever leaves a comment or answer!