Exporting to OSX app from Eclipse

I'm working on a fairly complex Processing project using Eclipse and I want to distribute it as a standalone runnable app. There doesn't seem to be a simple a way of exporting similar to the Processing IDE, in which the 'Export Application' functionality works wonderfully for sketches.

Any ideas on how to do this? Is it possible to import an Eclipse project back into the Processing IDE and to export it?

Answers

  • Processing requires native libraries that need to be specified before runtime. You can use a tool I wrote to create a self-extracting runnable jar that handles the native libraries for you though: http://StaticVoidGames.com/SvgExe/

  • Hi Kevin, thanks for your answer! I used your tool and managed to create a working Jar file, which requires a JRE to have been installed prior to running the program.

    The users who will be using my program are not very experienced using any type of software or computer, so having them install an additional JRE is not an option.

    I want the software to be installed/run very easily and would prefer if the JRE is included similar to how processing includes it in an exported a sketch.

    Do you know what the extra step would be once I have a runnable jar?

  • edited April 2014

    Many Java apps demand their user to install a JRE in his/her machine!
    That's announced right in the the download page at the requirement list.

    It's more appropriate for a user to install themselves big frameworks such as Java & .Net, etc. rather than an app bundled w/ it!

  • edited April 2014

    Why not package your jar with a runnable file (i.e exe file) that checks for java and clearly explains to the user if it is missing and what do do (and also runs your jar if jre exists). maybe your native executable could even install the needed jre?

  • While I agree that most people will have a JRE already installed, what you're asking about is pretty common. You can bundle your program up with a JRE as an executable (.exe on Windows, .app on Mac), and the easiest way to do that is by using JWrapper: http://www.jwrapper.com/

    That approach does have its downsides though: your program's size will be much larger because you're including the whole JRE, and you'll have to create OS-specific versions that your users will have to pick from.

    However, JWrapper automates the build process, and you can even set it up to only download a JRE if it can't find one on the system. This is how many "real" Java applications and games are run nowadays.

  • edited May 2014

    JWrapper looks good. My solution was to use a dummy app exported from Processing and paste the Eclipse jar in the app:

    1. First export your program to a runnable jar. (In Eclipse it's File->Export-> Runnable Jar File)
    2. In Processing, open a simple dummy sketch and export it to an app (FIle->Export applications) Make sure Embed Java is checked
    3. Go to the place you exported the app to, right click it and choose Show Package Contents
    4. Navigate to Contents -> Java
    5. Replace the .jar file in this folder with the one you just exported from Eclipse in step 1. Make sure the new jar file has has the same name as the one you are replacing.

    The app should now run the program. This is a quick and easy way to make a runnable app, no Java needs to be installed. As with JWrapper, this is OS-specific though my app was created on Mavericks and ran on older OSX versions.

  • I have done this but the app is not showing.

    If I go into the path of the app with the command line and type "open MyApp.app" I get this error:

    LSOpenURLsWithRole() failed with error -10810 for the file /Users/nkint/Code/Processing/MyApp/application.macosx/MyApp.app.

    What can it be?

  • Not sure if this helps, but one thing to check is a line in the .app's info.plist file. This key should reflect the package and class names (you should have a class that extends PApplet and contains main)

    JVMMainClassName package_name.MainClassName

    I was successful with a similar approach based on instructions I found at http://workshop.evolutionzone.com/2007/04/07/deploying-java-and-processing-applications-on-mac-os-x/

  • This might be a good place to share what I ended up doing, similar to TioPepe, but a few more details:

    In processing, export any working sketch that includes all libraries used in actual project. Do include the JRE. This gives you an .app, it just needs some adjustments.

    In Eclipse, export a JAR file: File->Export->Java->JAR file-> Export generated class files… & Export Java source files… & Compress… Put this file in .app/Contents/Java/

    Edit the .app (right click, show package contents):

    It turned out for me that a newer version of Java than was supplied by Processing gave me a faster frame rate, so I did this: Copy jdk1.8.0_40.jdk from /Library/Java/JavaVirtualMachines/ to .app/Contents/Plugins/

    Edit .app/Contents/Info.plist:

    Change this key to reflect package and class from your main class .java file JVMMainClassName package_name.MainClassName

    Also change the key about the JRE to reflect the newer version: JVMRuntime jdk1.8.0_40.jdk

    Copy data files from /sketch/data/ to .app/Contents/Java/data/

Sign In or Register to comment.