I have written a game with external resource files (images, sounds, etc..) in Java, which works on Windows when I export the .jar to .exe but not on MacOS when I export the .jar to .app .
I wrote the game in the Eclipse IDE and exported it as a runnable .jar file from there too.
My process for making it run on Windows is I first used an application called "Launch4j" to export from .jar to .exe . Then I made a copy of the folder I developed the game in so that all of the resource files are organized in the right way. Finally, I just put the .exe file in the main directory and it works.
My process for trying to make it run on MacOS was I first used an application called "AppMaker" on a Mac to export from .jar to .app . Then, I made a copy of the folder with the resources and put the .app file in, but it didn't open.
I noticed that if I exported a game without resources to .app and put it in the "Applications" folder on Mac, it worked, so I tried that with the resource game by putting my resource folders inside the actual Applications folder, but it also didn't open.
The only way I actually got a resource Java game to work on Mac was by not exporting it to a .app file at all and just leaving it as a .jar in the folder with the resources, but I really like how you can change the .app icon and it actually shows the file as an application.
Is there any way I can get my .app file with resources to run on MacOS?
I think that a FatJar might help you.
A Fat Jar is an archive which contains both classes and dependencies needed to run an application, here you have some info about it: http://tutorials.jenkov.com/maven/maven-build-fat-jar.html
Related
I have a project in eclipse which uses part of another java project for changing some variables. I need to create an executable file from my project but all instructions that I try doesn't work.
I created a runnable jar file by exporting my project but the jar file doesn't run. Then I used the launch4j to create an ".exe" file from the jar file but when I click one the .exe file instead of running, it unzips to a folder.
just in case if it is an important point, I am using mac os.
In Eclipse;
Click Next and give a destination
I am sorry if this question is placed wrong, but considering it is about jars and Java I figured it would probably be the closest to my subject.
I have a Java program of which I have made, this program I am going to distribute for Mac and Windows. To do this for Windows I have used Launch4j, which works without any issues. Now the problem is that when I try to convert the jar into .app for Mac, it doest work, the app just opens and then closes right after. I suppose this is because when converting to Mac .app using Appmaker it doesn't include the external libraries I have used for the program. Because of this I am now wondering how I would add the external libraries to the .app file like I have done on the .exe, where I have just added the .lib folder with all the external library jars into the folder where the .exe is in.
I have tried adding the .lib folder to the content folder which is created for the .app file, but that doesn't work, I have also tried adding it to the ressource folder within the .app file.
One of the options I have found myself is to combine all external libraries and the actual program .jar file into one. It just seems very difficult and really I don't need it to be just one combined .jar, if it can be included in another way.
Not sure of Appmaker but can do something like an uber jar, i.e. a single jar that contains all the classes, basically take all the jars unzip them to a signle folder and then jar them up again.
Not sure what you are using to build but maven has a maven shade plugin that does exactly this.
I am trying to export my Runnable Jar file that includes the image resources that goes along with my program. When I run the program in eclipse the paths work perfectly but when trying to export the program there are no images. I have been exporting by choosing the package all contents option.
Since your image files are stored in jar as resources you should retrieve them as resources. Hers is how
I have just finished developing a small java application on Netbeans IDE. I am curious as to how I can convert that into an executable program from netbeans. So that there would be a short cut icon which when double clicked loads all classes and runs the main function with all relevant jar files also compiled. i.e. JCalender, JTatto, aswell as sqlitejdbc.jar. all of which are in a directory of the project.
Look into Launch4j, a Java program that can turn your .jar file into a standard Windows Executable .exe file while building all references into that single file.
I have made a simple GUI using slick and lwjgl, I am using eclipse and have imported my jars, natives and images to my Java build path, I export my code as a jar file and get a jar file on my desktop, I try open it with SE Binary and it loads for a little while then nothing happens.
It may have something to do with how I have imported them into my build path, I will try explain, I have inside my Java project two additional folders that I have created, they are lib and res, res holds all of my images and lib holds two other folders called jars and natives, jars holds two jar files (slick and lwjgl) and natives holds 4 other folders (windows, linux, mac, solaris natives), I imported my 2 jar files into the build path using the add jars option, I then imported my res file using the add class folder option and after that using the same option I imported the lib folder, I then exported it and now it doesn't open.
It may be worth mentioning that before I export my jar files from eclipse I get the following pop up message: The operation repacks referenced libraries.
It seems that lwjgl can't use the native libraries when they are inside a jar archive.
The solution is to unpack your natives folder either into some install directory or a temporary directory. Then, before you use any lwjgl function, you need to set the new path to the natives. For example with the files unpacked in "lib/native" I use
System.setProperty("org.lwjgl.librarypath", (new File("lib/native")).getAbsolutePath());
System.setProperty("java.librarypath", (new File("lib/native")).getAbsolutePath());
System.setProperty("net.java.games.input.librarypath", (new File("lib/native")).getAbsolutePath());
This seems to be the easiest solution. For example minecraft (which uses lwjgl) unpacks the natives to "%appdata%.minecraft\bin\natives" (on windows, ~ instead of %appdata% on linux).
Edit: a very related wiki page: http://lwjgl.com/wiki/index.php?title=Distributing_Your_LWJGL_Application