开发者

Deploy Java application on MacOSX (from a Windows system)

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 开发者_JAVA技巧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:

Deploy Java application on MacOSX (from a Windows system)

Thanks in advance.


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜