Search code examples
javajarexportexebluej

How to export a BlueJ Java Project into an actual exe-type program (not Jar)


I have a BlueJ project (don't judge me I'm trying to learn Eclipse) and it uses functionalities like JPanel and PrintWriters - it basically takes input txt files in the project folder, manipulates them, and then exports the manipulated data to an "output" txt file, also in the project folder. Is there some way to turn this into an executable version so that other people can use my utility without having to download BlueJ/IDEs? I already tried exporting to Jar file, and it doesn't have all the folders for inputs/outputs so I don't get how I could do it (yes I have heard of "wrapping" a Jar file in an exe but I obviously can't do that either).

Thank you for any help, and please tell me if you need more info, this is my first StackOverflow question! :)


Solution

  • It looks like you wouldn't want the input/output folders wraped in the jar, since they wouldn't be accessible without cracking the jar open...

    This is how i would do it: I'd export the jar, then wrap it with this tool: launch4j. It's pretty straightforward to use. You don't have to make use of everything it offers, just specify the jar and the JVM arguments and hit the create button. the resulting exe will include your jar. If you give launch4j the path to your JRE, it can also include that in the exe, thus making it completely standalone. (never tried this myself, though)

    The input/output folder paths will be the same as in the jar version - relative to where the exe/jar is. So if you specify an output location as new File("output/sometext.txt"), the resulting file will be in a folder named "output" within the same folder as your exe is in. Same with input, of course, just place the files for manipulation in a folder named "input" within the folder where your exe is, and specify it in the program as "input/sometext.txt".

    Not shure if that's what you wanted to know... hope it helps!