views:

84

answers:

3

Hello,

Here's the deal. I'm just starting with Java programming, I've made a simple application that uses SWT graphic library and I want to deploy it on a Mac (running the latest version of MacOS X). I did all the programming in my Windows 7 machine, so here are my questions:

Q1) Can I make an executable file for MacOS X from my Windows machine? How? (I saw that it's possible to create .exe files on Windows, instead of using .jar; I want to do the same for the Mac, of course it won't be an .exe)

Q2) If I export my project in Eclipse and I choose Runnable JAR File and then on Library Handling I pick Extract required libraries into generated JAR or Package required libraries into generated JAR I end up with a huge .JAR (about 15MB of size, my application consist in just a button on a Window and a tiny method that doesn't do much). Is that considered normal? Here's the list of libraries that my project appears to be using:

alt text

Thanks in advance.

+2  A: 

Q1: You have to bundle the jar inside an application bundle, there is this tutorial directly from Apple..

Q2: Yes, it's 15mb because all the referenced libraries that does not reside inside the JRE System Library are included inside the final jar. There are different approaches:

  • bundle all together like you are doing
  • bring other .jars together with yours without packing them
  • install the jar separately, they must be copied once into $JAVA_HOME/lib/ext and then every application on the same JRE will have them
Jack
Thanks. BTW, about the 15mb file, I realized that there were a lot of unused libraries, after removing all and just leaving SWT I got a 1.4mb file :)
Matías
+1  A: 

In order to export an application to multiple platforms, install the Eclipse Delta pack on you development machine. Here's a tutorial. After you install it, you can export your eclipse application to any target (Windows, Linux, OSX, etc).

EDIT: Here's another tutorial.

drstupid
Thanks for replying. It's not that easy though, can you point me to a good tutorial or documentation on how to use that? (Installation was the easy part)
Matías
Actually, it's all in there. When you export your product with the eclipse export wizard (to generate the *.exe file), just check "export to multiple platfroms" in the wizard.
drstupid
+1  A: 

Save yourself some grief and convert your eclipse project to a maven project and then use the OSX App Bundle plugin: http://mojo.codehaus.org/osxappbundle-maven-plugin/ . Maven projects are easily loaded in eclipse through either the use of mvn eclipse:eclipse or by using the m2 plugin.

If you need to build for both Windows and OSX, set up two different build profiles in your maven pom.xml to call the appropriate bundler.

whaley