Installing and Running Java application on Macs - java

I have a java desktop application for which I am trying to create a Mac application package. The application is composed of two runnable jar files and several folders of text and images. The first jar acts as an updater and launcher for the second jar which is the bulk of the application. The application uses a variety of data files and images that are referenced in the application by relative path name (e.g. ./images/bits/xyz.jpg).
On Macs, however, I am having trouble getting the relative pathnames to work after creating a Application Bundle with Jar Bundler. I have no personal experience with Macs and need help understanding the standard way to laying out an application on them. I have noticed that other applications that I have installed come as a disk image file that opens with instructions to drag the app into the applications folder. I am trying to create a similar install package. Thank you in advance for your advice.

Drag and drop instruction in a disk image is a complete red herring. Once the app bundle is correctly made, it does not matter whether it's in the disk image or it's just zipped.
Note that on Macs, executables (whether native Cocoa or Java) don't have its current directory set to the path of the executable. So, you first need to get the current absolute path of the jar file, say. For that, there are already Q&As on Stack Overflow. See e.g. here.

You might need a Mac in order to create a proper Java Bundle and a DMG file.
Here is a simple example:
http://www.centerkey.com/mac/java/
And here is a tutorial on how to make use of Mac-specific Swing features:
http://java.sun.com/developer/technicalArticles/JavaLP/JavaToMac3/

As a developer with Pyxis Software, I would like to add that we have developed an application that solves this issue. The application named Pyxis Bundler will automatically bundle your jar file and optional libraries into a standard Mac application.
You can optionally embed the JRE from your JAVAHOME directory or select a specific JRE. While this will clearly enlarge the size of your application, the user does not need to have JAVA pre-installed on their machine to run your application.
There is also an option to create a modern Apple Icon image (multi size ICNS file).
We designed this as a replacement for the Jar Bundler application that used to be shipped with Xcode up to a number of years ago.
Pyxis Bundler saves each unique application settings to a preferences file, so if or when you update your Mac application, you only need to select the application name from a drop-down list to load all previously used data for that application. Then simply increment your version number and click the Create button.
I should add that with Pyxis Bundler you must use proper package names.
More information is available here:
https://explorepyxis.com/shop
http://www.pyxis.ie/explore/index.php/software/pyxis-jar-bundler
You can check-out how to name packages here: https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html

Related

Derby embedded executable jar suddenly read only [duplicate]

I am developing desktop database application. Using rdlc report and reportviewer. Everything was fine in developing process, reportviewer was showing all data smoothly. I deploy app with Inno Setup. But when I install the app, the reportviewer is not showing data. While data is correctly inserted in the tables.
For applications that work incorrectly or fail completely, when installed by Inno Setup to Program Files folder, the first thing to test, is to try to deploy the application manually to the same folder.
If the application fails even after a manual deployment, the most usual problem is that the application requires a user to have write permissions to application folder. As on modern versions of Windows a user typically does not have write permissions to the Program Files folder, the application does not work. So the problem usually has nothing to do with Inno Setup, but it's a problem of the application itself.
To solve the problem:
The best solution is to redesign the application so that it does not require write permissions to its folder. Windows applications should not require write permissions to their folder. That's against Windows guidelines. The application should write data to a user profile folder (C:\Users\username\AppData) or to a common data folder (C:\ProgramData).
A dirty workaround is have the installer grant a user(s) write permissions to the installation folder. Do that only, if you cannot get the application fixed (e.g. it's 3rd party application).
See Inno Setup - How to set permissions of installation folder.
Even more gross workaround is to configure the application to be executed with elevated (Administrator) privileges.
See Inno Setup desktop shortcut (link) which has "Run as administrator" advanced property set
or How to set 'Run as administrator' on a file using Inno Setup.
Another solution is enabling legacy compatibility mode that makes Windows redirect all application write attempts to a virtual store. See also Application installed with Inno Setup writes files to unknown location instead of its installation folder.
There are numerous other possible reasons, why the application might be failing when installed, including:
You omitted some dependency:
DLL library
.NET assembly
.NET Framework
Java Runtime Environment
other runtime
COM/ActiveX object, etc.
The application requires some configuration:
a file
a registry key [including COM/ActiveX object registration]
an environment variable, etc.
The application is not designed to be executed from a folder that has a space in its name (Program Files).
The application gets confused by Windows File virtualization (though it's unlikely). See Application installed with Inno Setup writes files to unknown location instead of its installation folder.

How to export my program into a runnable desktop file?

first time posting here, java beginner.
I made a basic calculator that receives user input. Is there a way to export my program to make a runnable desktop file?
My IDE is IntelliJ.
Thanks in advance!!
Assuming you are building a JavaFX app:
The easiest way to deploy your app is to go to File>Project Structure>Artifacts.
Add your available elements (if you have any extra images etc) into your output root, and click on your jar file. At the bottom of the window you'll see options to either create a manifest file or modify an existing one.
The manifest file describes the first class to load in your program (the starting point) as well as the locations of any third party libraries you may have included in your program.
You will also have a JavaFX tab that you can use to set some initial parameters for your app, such as the title, version, and whether you want to deploy any native bundles (eg: .exe for Windows, .deb for Ubuntu etc)
Once you have configured the important parameters you want, save your settings (or just select any field and click enter) and go to Build>Build Artifacts>Action: Build
IntelliJ should generate an executable .jar file and any native bundles you selected. The native bundles can just be double clicked, and the jar file can be run using a JRE.
On blog.jetbrains.com they show the steps with some screenshots.
Note that this entire process is called deploying your app and there are a variety of tools and methods to do it. I just described what I believe is the simplest way.

How to deploy jar both with Web Start and an installer?

I have a Java desktop application and now we distribute it as a jar in a installer of a main application (currently the Java application is only an importer/exporter). But as the jar is updated more often than the main application we are thinking of making it run through Java Web Start so it's updated independently when it start.
My question is how can I distribute it in the installer so if the user don't have internet it use the jar bundle in the installer (and copied in the main application folder) but when he launch and have internet, Java Web Start update it?
Edit: I have think in making two JNLP files one for local launch and one for online launch so it get updated, but then they need to share the cached jar so isn't installed two times, and I don't know if this is possible.
Edit, more explanations:
Maybe I haven't explain it very well. I have a native application and is distributed as an MSI, from download and through CD. With this application we distribute the Java application (a jar) that the main application used to exchange data to other formats. The MSI installs both the native app and copy the jar (not really install). Now if the user have internet and a new update is published, the complete MSI is downloaded and installed (updating the installation). Ok?
Well, we like to update only the jar in a more fashion approach, with Java Web Start, so it's updated when the jar is run independently of the main app. This have the problem that if we only deploy it as Java Web Start, if the user install the app in a computer without internet (for example carrying the MSI in a pen-drive or cd) he will not be able to use it, because as he don't have internet he can't download the jar.
And now is when my question come, can I deploy the jar in the MSI but execute through a Java Web Start so if the user have internet it get updated but if he doesn't have internet it still can use the bundle jar in the MSI?
..can I deploy the jar in the MSI but execute through a Java Web Start so if the user have internet it get updated but if he doesn't have internet it still can use the bundle jar in the MSI?
OK, I am formulating a plan here, this might be doable.
Let us presume that the MSI is capable of doing the following things.
Install a JRE if missing or too low a version available. The JRE needs to be included in the MSI (to avoid requiring the net).
Unpack the JWS launch file and Jar(s) (and native..) to the local file system as temporary files.
Invoke the javaws tool using 'IMPORT-OPTIONS' to set the code-base to the place in the local file-system they were unpacked.
At this point, desktop icons and shortcuts should be installed, and the program ready to launch. It is vital to specify a few extra options in the JNLP - specifically offline-allowed to ensure the app. can still be launched if the internet is not available.
Caveats: I don't have any experience with MSI, and my experience with using the import options is limited to calling them from build files (during development).

How To Make a Mac Application/Installer (Java) Properly on Windows?

I simply want to make a JAR file or APP file from my Windows machine that mac users can run and see a more professional application.
Most importantly, I want the menu bar title to say the program's NAME not the launcher package! I find this really annoying since, when programming for Windows, you don't have to worry about that kind of crap. Windows just shows the user whatever you name your JFrame when you create it. Mac puts the full Launcher package name in the upper left-hand corner:
i.e. com.blah.initial.Launcher
I've learned some from a Java Tutorial that covered bringing Java applications to Mac, but it didn't talk very much about how to do it from a Windows machine.
I am aware that an XML file is needed to tell the Mac program information.... but I'm not sure how to create and package all of it on Windows.
Any help would be appreciated.
As seen in this example, a Mac application bundle is just a directory tree with a name ending in .app. Once everything is laid out, just build your JAR and copy it to the destination directory, as shown in the build target of the project's build.xml.
Do JWS applications show the application title in the task bar?
Mac OS X has both menu bar and dock; the latter is similar to the task bar. In both,
When double clicking an unadorned JAR, the fully qualified Main-Class name appears.
When launched via java-web-start, the name is taken from the the title property.
For an application bundle, the name is taken from the -Xdock:name property.

Running Eclipse Equinox and an Application from a single Jar using no other files

I have an application that uses the Eclipse runtime. Unfortunately, due to restrictions in Equinox (the Eclispe OSGi implementation), it's not possible to start the Eclipse runtime with all of the plugins on the classpath, so it must actually be located on the disk. (There is code that insists to look for the OSGi framework bundle using a "file:" URL protocol).
I need to have my application (with Eclipse) be in a single JAR file and have no dependencies on external environment variable settings. You should be able to call my app's API like any other and it should just work. How I have implemented this is to create a temporary directory using the Java temp file support (i.e. File.createTempFile()), and then I read all of the plugins and some other stuff from the classpath and write it to the disk so there is the expected Eclipse installation. This is about 10MB worth of stuff and takes IIRC less than a second. However, I would like to avoid even this if possible by checking to see that it has been done before and not doing it again unless there is a problem.
One way that occurs to me is to write some other small file in a known location (like in the user's home directory) that contains the version number of my code and a pointer to the temporary location. Another alternative is to locate the installation in a known place (instead of using the Java temp file support). But then this gets messy with platform specific considerations.
Anyone have a better idea for how to solve this?

Categories

Resources