We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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?
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!
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.
JWrapper looks good. My solution was to use a dummy app exported from Processing and paste the Eclipse jar in the app:
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:
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/