|
Author |
Topic: making .exe, .jar, and .app files from p5 projects (Read 11301 times) |
|
fry
|
making .exe, .jar, and .app files from p5 projects
« on: Jun 10th, 2004, 3:40pm » |
|
a short howto on making double-clickable processing applications using .exe, .jar and .app files. * download the files for this tutorial from: http://processing.org/download/distribution.zip * i wrote this up because folks keep asking about it, and it may be a little while before 'export to application' is completed. * this stuff will no longer be necessary when the 'export to application' feature is completed for processing. * use at your own risk, this might be a pain in the butt, or it might work just fine for you. * making these files include serial, net, video or other libraries is more difficult, this is part of the holdup on just making that work in processing itself, since a complete solution is needed. * more features, like a better method for adding additional items for the classpath, or changing the memory setup would be nice.. * corrections and additions are welcome, i'd love for this to be more complete but am too busy to improve it for the time being. * good luck! - ben fry / 10 june 2004 EXECUTABLE JAR FILE this is a double-clickable .jar file that can be run from most systems. first, add the following lines to your application: static public void main(String args[]) { BApplet.main(new String[] { "sketch" }); } where "sketch" in quotes can be the name of your exported application, so that it properly finds it. next, unzip the .jar file created by processing into its own folder. then inside that folder, create one called META-INF (all caps) and within that, a file called MANIFEST.MF. in that file write the lines: Manifest-Version: 1.0 Main-Class: sketch change the main class to whatever your app's name is. if you unzipped your files to a folder called 'stuff', the contents should now look like this: stuff/ Sketch.class META-INF/ MANIFEST.MF BApplet.class BGraphics.class ..etc now, zip up the contents of 'stuff' (or whatever you called it), into a file called sketch.jar or whatever you'd like to call it. make sure you zip the *contents* of the 'stuff' folder, but don't include the 'stuff' folder itself. if you have a command line zip program (macosx and linux have this by default, windows you'll want to download info-zip or cygwin), you'd do something like this: cd stuff zip -r ../sketch.jar * MAC OS X macosx.app is an "application package", specially designed for the mac. on macosx it'll show up as a double-clickable application, on other platforms it's a folder. inside the folder is another called "Contents", and within that a filed named "Info.plist". it's an xml file with all the java parameters, generated using on of apple's java application bundling tools. everything is set to assume a program named 'sketch' in a jar file called 'sketch.jar', and should be placed in: Contents/Resources/Java/sketch.jar relevant keys you might want to mess with: CFBundleName -> set to the application's "name" VMOptions -> two entries here, -Xms512m and -Xmx512m, which must be in that order. this allocates 512 mb to the app, which is probably overkill for most applications JVMVersion -> set to "1.3" to require 1.3, set to "1.3+" to mean any version 1.3 and higher, or "1.4" to require java 1.4. Classpath -> set to include sketch.jar, modify to suit yourself. MainClass -> class containing the "static public void main(String args[])" line. if this file is built on another platform (ie windows) you might need to open up a terminal, go to the folder that contains the application, and type: chmod +x macosx.app/Contents/MacOS/JavaApplicationStub to make the file 'executable'. this solves a problem where you double-click the app and it bounces in the dock briefly before quitting. WINDOWS this is a modified version of the processing.exe program. it's not as clean as the mac solution, simply because i haven't had the time to make it so. if your program is just named 'sketch', make a sketch.jar file, and place it inside a folder called 'lib', next to sketch.exe. in this case, just use the 'windows' folder. if you need to make changes, use the contents of the windows-build folder to build your own version of the application. the application is built with cygwin or msys. the relevant lines, if they need to be changed are found in launcher.cpp: #define JAVA_ARGS "-Xms512m -Xmx512m " #define JAVA_MAIN_CLASS "sketch" * be sure to include that space at the end of the JAVA_ARGS stuff * after altering these, you can type 'make' within that folder, from a command line, to get the thing to rebuild. do distribute a jre along with the app, place it in a subfolder called 'java', just like the way that processing (standard vs expert) is done. so a subfolder called 'bin' of that java folder will contain the actual java.exe.
|
|
|
|
skloopy
|
Re: making .exe, .jar, and .app files from p5 proj
« Reply #1 on: Jun 10th, 2004, 11:38pm » |
|
Awesome! Thanks Fry I know i'm gonna need to use this soon. For mac people, I think you have to use a program like pico (just type pico int the terminal) to make the MANIFEST.MF file. TextEdit uses the wrong encoding or something I think. I had to do the chmod -x like fry suggested to make the app work too. Hmm now i wonder how you can make a custom about box and menus..
|
|
|
|
mattgilbert
|
Re: making .exe, .jar, and .app files from p5 proj
« Reply #3 on: Jun 11th, 2004, 6:56am » |
|
works like a charm on mac! thanks so much ben! this will be quite handy! on Jun 10th, 2004, 11:38pm, scloopy wrote:For mac people, I think you have to use a program like pico (just type pico int the terminal) to make the MANIFEST.MF file. TextEdit uses the wrong encoding or something I think. |
| Mac people can use Textedit. You just have to go Format>Make Plain Text, or press shift+apple+t before you save the file. Matt
|
|
|
|
arielm
|
Re: making .exe, .jar, and .app files from p5 proj
« Reply #4 on: Jun 11th, 2004, 4:03pm » |
|
2 quick questions: if i package a .jar file with a manifest on pc, will it work on mac? if yes, will it work on macs without sun's java? (i mean with that mrj thing... or this point is not relevant since sun's java is installed by default on osX?) 10-x
|
Ariel Malka | www.chronotext.org
|
|
|
fry
|
Re: making .exe, .jar, and .app files from p5 proj
« Reply #5 on: Jun 11th, 2004, 6:31pm » |
|
on Jun 11th, 2004, 4:03pm, arielm wrote:2 quick questions: if i package a .jar file with a manifest on pc, will it work on mac if yes, will it work on macs without sun's java (i mean with that mrj thing... or this point is not relevant since sun's java is installed by default on osX) 10-x |
| re #1, double clicking a .jar on the mac will work just fine, and it'll load up as an app, at least on macosx. re #2, macosx comes with apple java already installed. no sun java. macos9 usually has java, though less and less people are (finally) using macos9.
|
|
|
|
parutron
|
Re: making .exe, .jar, and .app files from p5 proj
« Reply #6 on: Dec 15th, 2004, 4:25am » |
|
hi. i've had much success following ben fry's instructions (after he de-virginized me by helping me the first time) for making an executable. one thing that i don't know how to do that i want to know how to do is give my application window a name. following the instruction, after i double clik on my .exe, a window pops up (and does it's thing), but that window has only a java icon to identify itself. thanks for the help. over and out. (ben fry rocks the body) parutron.
|
|
|
|
toxi
|
Re: making .exe, .jar, and .app files from p5 proj
« Reply #7 on: Dec 15th, 2004, 12:21pm » |
|
parutron, a while ago i made a launcher tool for standalone sketches for which you can specify a window title or run in fullscreen mode. it's a slightly different approach to ben's, but should not require any code changes. more info in this thread. good luck!
|
http://toxi.co.uk/
|
|
|
minh
|
Re: making .exe, .jar, and .app files from p5 proj
« Reply #8 on: Apr 2nd, 2005, 7:50am » |
|
this pretty much works with everything except for serial and video... in the future version where you can make an executable, will the application work with serial and video? just curious, why doesn't it work?.. is it because of the nature of BApplet where the serial and video libraries doesn't work with an applet?
|
|
|
|
|