I'm looking to deploy my Java app to MacOS, and the most common way seems to be a DMG file that contains a symlink to the application folder and your application (and you drag one onto the other.)
I'd like to be able to generate the DMG file cross platform via ant - specifically on Windows (though a cross platform Java ANT task would be best!) The only options I've thus found are from this question and either fall under the category of paid applications or Linux commands.
If not, are there any sensible alternatives to a DMG file that would be easier, but still provide the same (or very similar) level of user familiarity? By sensible, I definitely don't mean alternatives like "Just build on a Mac"!
EDIT: I'm currently using JarBundler, but I've yet to find a JavaApplicationStub that works alongside Java 7 (my application requires Java 7 unfortunately which is a bit of a stumbling block it seems!)
Check this out for building Mac apps from Java 7:
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html
Related
I have never used mac before so I have a question about best way of running java application on mac, since I didn't really find a good answer online.
So I've build a java application and I have to send it to a client that is using mac. I know that you can run .jar on mac using java -jar app.jar from terminal, but I want a double-clickable icon that a client can only click on and start the program.
I've seen some tutorial where someone has made a .jar file that you only double click on and the program starts in macos, so I am not sure if you can run a .jar in macos as executable only by double clicking on it?
One other solution that I saw was to make a simple .command file that would run the app using java -jar app.jar. So I want to know what is the best way of making an executable for mac from a .jar file?
Yours isn't a bad question.
The answer is "it depends". It's entirely possible the "best solution" is to simply send the .jar file with instructions for invoking it.
Please look at the Oracle documentation:
Java Documentation Section 7: Self-Contained Application
Packaging
7.1 Introduction
The Java packaging tools provide built-in support for several formats
of self-contained application packages. The basic package is a single
folder on your hard drive that includes all application resources and
the JRE. The package can be redistributed as is, or you can build an
installable package (for example, EXE or DMG format.)
From the standpoint of process, producing a self-contained application
package is similar to producing a basic application package as
discussed in Chapter 5, "Packaging Basics," with the following
differences:
Self-contained application packages must be explicitly requested by passing additional arguments to the Ant task or
javapackager tool.
Operating system and tool requirements must be met to be able to build a package in a specific format.
Self-contained application packages can only be built using JDK 7 Update 6 or later.
While it is easy to create a basic self-contained application package,
tailoring it to achieve the best user experience for a particular
distribution method usually requires some effort and a deeper
understanding of the topic.
...
7.3.5.1 OS X
The resulting package on OS X is an "application bundle".
Several configuration parameters are placed in the Info.plist file in
the application bundle and must conform to the following rules:
Application ID (or main class name if ID is not specified) is used as CFBundleIdentifier.
Application version is used as CFBundleShortVersionString.
OS X 10.8 introduces Gatekeeper, which prevents execution of untrusted
code by default, regardless of whether this code is implemented in
Objective-C or Java.
The user can manually enable the application to run, but this is not a
perfect user experience. To get optimal user experience, obtain a
Developer ID Certificate from Apple. The Mac bundler uses the
certificate to sign the .app folder. If your local user information
differs from the name of the certificate, you might need to set the
bundle argument mac.signing-key-user-name, as shown in the following
example:
We currently ship a java(jar) installer of our application. Taking into acount the changes to jdk11 we want our users to have the same easy install experience. So, what we are looking for, is to have just one file that can be run even if there is no java installed, it should just start our old java installer.
Probably, this means that we jave to bundle the jre and have a script that runs the jar, but the problem is how to run the batch file natively ? We need this to work on Windows and Mac. Most tools we are looking into require java to run the wrapped jar.
You have to build 2 different scripts/installers, one for each platform. Even looking at very popular software like Chrome, the platform choice is still there (even though you're usually directed to the correct choice based on the information your browser provides them with)
Depending on how much time you can put in this task, the quickest (and dirtiest) solution would be having an archive for each platform that contains the script .bat for Windows and .sh for OS X together with the jre (also different per platform), ask the user to unarchive and run the script which will run your jar with the packed jre. Otherwise, you'll need to create an MSI/exe for windows and a dmg (or other installer type) for MacOs.
I have done the dmg before with a bundled jre and can try to look for the details if you need them (I no longer have access to the code but can probably find the details). It was a free solution but it did require an OS X computer to create the dmg.
One option that I used before and works very well is install4j but the price is not small.
LE: Self contained packaging - although I haven't used this before, it seems like the best current option for your problem.
And an open source option - packr.
that Self Contained packaging doesn't really help, same for packr, same for launch4j. Because all those just generate a application image with a lot of files and directories.
Problem is before that, as an installer you want 1 big exe (or dmg for mac) that does it all, single click
We are already at the stage like SCP or Packr. Because that is easy or current installer.exe and jre\ sub dir and a batch/sh file besides it. Problem is how to get from that directory structure to a single exe that runs.
So what we should have is something that can zip that in a self extracting archive, when clicking on that it should auto extract to the temp dir of the OS, then run directly a command on it (like a batch file or directly in that extracted dir: .\jre\bin\javaw.exe -jar installler.jar)
But nobody seems to have made such a thing, the closest that we have is eclipse with Oomph:
[1] https://git.eclipse.org/c/oomph/org.eclipse.oomph.git/tree/plugins/org.eclipse.oomph.extractor/src/extractor.c
[2] https://git.eclipse.org/c/oomph/org.eclipse.oomph.git/tree/plugins/org.eclipse.oomph.extractor.lib/src/org/eclipse/oomph/extractor/lib/BINExtractor.java
problem is a bit that is doing the extracting through java and still wants a vm first.
When the program is installing on windows, I want the installer to check if mysql is installed, and install it if it isn't (Or at very least give a link to the website so the user can install it)
I'm sure this is possible, I've been trying to figure this out for a while now. If you can have an installer check if the user has java installed and install it if they don't, then surely you can do the same for mysql?
Perhaps I'm looking at this the wrong way - should I instead be getting the java program to check if mysql is installed and install it then if it isn't? And if so, how do I do that?
Any help would be hugely appreciated, I've been stuck with this for a long time.
I refer to this answer.
Java is cross platform, MySQL isn't, so you'd have to create various installers for multiple platforms with different MySQL binaries.
My suggestion is to have a look around the web in order to find the correct way to create an installer depending on the OS you're using
Installer is usually created for OS (Windows, Linux). In our case we created deb package (for Debian) which checked if PostgreSQL and other prerequisites are installed and installed what is missing. So, basically it is job for installation script (in our case it was shell).
Wix installers along with .bat files you can use.
http://wixtoolset.org/
It has built-in directives that can check if software is installed or not, outdated version notifications also.But WIX is kind of a database of your software binaries.So you have to include the binaries of MySQL(whichever are supported on windows) in the installer using harvest wix utility.
http://wixtoolset.org/documentation/manual/v3/overview/heat.html
This will just copy the binaries in your target directory if the software is not installed, you have to write all this logic to skip or install using wix directives/conditional custom actions .To do after copy stuff like starting or configuring the service either write a bat/powershell file which will handle all this and you can invoke this powershell file from wix after the copy action using wix custom action directives.
http://wixtoolset.org/documentation/manual/v3/wixdev/extensions/authoring_custom_actions.html.
Or you can write all the steps of bat files in many different custom actions.You will need visual studio to create this installer.In the begining it will be trouble to understand how it works but this is the best way to create production level deployment/product installers for microsoft suite.
I want to use QT Jambi for GUI (Java project). The GUI needs to have animations (similar to Iphone apps). That is why, I do not want to use Java Swing.
My question is, after I develop the application, is there any automatic mechanism which would create a setup file which could be used to install my application in any computer (may be separate "setup" files for separate OS). In other words, I would like my users to download just one file: setup.exe. This should install the app in their computer.
I know there is one such app for .jar files (I forgot the name). But QT is a C++ library and I do not like bothering the users, asking them to download QT just to use my app.
I presume you are tagetting win32 only on the desktop and looking for free/open tools. With no response to this questio so far I thought I'd provide some info towards this point even if it is not the answer you really want.
I have been looking over the QtJambi ecosphere for the past couple of years and I'm not aware of such a tool to provide you with a process to follow that results in an EXE. There are all kinds of caveats.
The task:
Ensure the JRE5+ is installed on target system.
Ensure QtJambi files and perform things like extraction of native JAR.
Ensure QtJambi pre-reqs are installed on the target system (such as MSVCxxxx runtimes).
Finally install your application and fixup the startup configuration to make use of information above.
Setup desktop fo reasy access (Program Group, Desktop Icon, Menu items, Shortcuts)
You will find that NSIS http://nsis.sourceforge.net/ can be a tool to get some parts of the process and maybe provide a framework to write modules for NSIS that do other parts of the work. But I have found NSIS somewhat lacking when you step outside of a simple unzip of data and setup of desktop install process.
Another solution for you would be to simply provide everything that works in one ZIP file, this would include a copy of the Java JRE embedded, a copy of QtJambi embedded, the rest of your JAR and then write a toplevel *.BAT file to setup %PATH% and other arguments to run your supplied java.exe against your application. Obviously now the JRE is not likely to get updated so at some point will be considered insecure.
NSIS isn't the only such windows installer that exist.
Maybe there is a fully automatic one click install wrapper with custom parts to help setting up QtJambi, but I doubt it at this time.
Good question, and one good attempt at an answer.
I've gone down a slightly different route: embed the Qt Jambi libraries, but not a JRE. I have some basic sh/bat launch scripts which configure the resources required and am using IzPack for the installer (though NSIS might be a good alternative).
Problem: how to find the JRE
Solution: the IzPack installer needs a JRE to run, so guarantees the availability of one. It can update a variable in scripts during installation.
Solution (Windows): use the registry
Last resort: use the path
The ideal would be to integrate all three into a batch file. Anyone done this?
Problem: Qt & Qt Jambi libraries
Solution: distribute with your application and link from the shell/batch file.
The problem with this is how to make sure your libraries get used when binary-incompatible Qt libraries are already installed on the system. On Linux, extracting the libraries and exporting LD_LIBRARY_PATH seems to work. On Windows I haven't solved this and on the Mac I haven't tried.
Problem: most appropriate Qt libraries
32-bit Qt libraries probably won't work with a 64-bit JRE; this is a problem I haven't yet had to deal with. Probably the best solution would be to include both 32-bit and 64-bit Qt libraries and select between them from a script at run-time (or possibly install-time).
Another issue is related to themes: Qt has support for using native themes, but only from the platforms it's compiled on. Thus, compiling Qt on an old Windows version and using the libraries on a modern version of Windows seems to work but results in ugly Windows-98-esque widgets. The easiest solution seems to be to launch with -style Plastique (or cleanlooks) to get nicer-looking widgets.
This is still awhile down the road for me but for my Project Implementation class we have to create a program and then distribute it. I have written an application in Java and from the specification I have made in the previous class (Project Design) my application will need to be platform-independent.
For mac and linux the user can just run the jar file from the terminal, but for windows I would like to have the Application installed to the path user chooses (default: C:\Program Files(x86)\NameOfApplication), Create a desktop shortcut (if the user wishes to have one), install under the start menu (if the user wants it to) and then also show up in the add\remove programs list.
Is there any easy way to do this?
Is it any harder if I did decided to create an installer for mac and linux?
Thanks in Advance.
You can create an installer with NSIS, even for a Java application.
You might also consider distributing your application via Java Web Start.
There are opensource installer generators for java. I have never used one before. Here is a good resource of links
I recommend using Java Web Start.
It has several advantages.
Available for all major desktop platforms
Single distribution for all JWS-enabled platforms
Code-signing and sandboxing
Versioning and incremental updates
Automatic installation of JREs and optional packages
It has one major disadvantage.
Internet connectivity is required if JWS, JRE, and/or an Optional
Package is not present on the system
Have a look here and here
Install4j does what you want, although you have to pay for it. Personally, I am not aware of any free alternatives. You can make installers for Linux and Mac OS as well.
you can use Exe4J, see http://www.ej-technologies.com/products/exe4j/overview.html
You can do most of that using standard JNLP:
http://docs.oracle.com/javase/1.4.2/docs/guide/jws/developersguide/syntax.html
You make a JNLP file that takes the executable JAR from some local (or remote) location and creates a Desktop icon for it (of your chosing). Only difference is that the actual JAR will be placed in the JDK's jar cache directory (not in a directory of your choice - I don't think the user would care much).
The huge advantage with this is that if you make a JNLP that installs the jar from a remote location, you can remotely upload a new version of the jar to that location, and when the user next accesses the jar locally, your latest version will be downloaded and placed into local cache.
Also I recommend you use a smart "fat JAR" builder, which packages all dependency jars inside the executable jar. Eclipse IDE has a way to export a project in this format (and also adds the necessary class-loader so that all works ok from on fat jar).
If your target OS is windows I highly recommend Advanced Installer. It's very very easy to use and will let you create your own native microsoft installer (.msi) with specific target Java VM and a bunch of useful windows features, even in the free version. Note you can also include a private jre into the package.
http://www.advancedinstaller.com/top-freeware-features.html
If you want a "package one deploy everywhere" solution then IzPack is the way to go, platform independant, free and open source.
http://izpack.org/
Depending on the complexity of your project Java Web Start could be a very good option, it's very simple configure and maintain but it relies on the browser's java plugin and believe me... most users DON'T like being warned about certificates and risks everytime they launch an application.