I build the app image, i.e, the entire working application which includes the jre.
This is saved to the build folder.
Zip the app image up and distribute it as is.
User can unzip it wherever they want.
I can then do as was mentioned and check location, try writing a file, moving a file, whatever, before running app and display an error message and bail if I cant do that.
The app runs just fine when using the scripts that are in the app image.
This will speed up build time as you donât have to run jpackage to build the installer, just the app image, which is blazing fast.
Basically just a distZip that takes the hassle out of packaging the jre.
Sorry, I thought you knew. The Tilde notation is an *nix shortcut for âUser Homeâ in a terminal/shell. (Command Line/script environment) Many of the forums that I see tend to use it as slang for âUser Homeâ on any platform, even though it may need to be represented differently in the programming environment they are working with.
Jpackage seems to be assuming that only a system-wide install is acceptable, which is another reason that I probably wonât be looking closer at itâŚ
Its only good for packaging the jre now. As it requires a machine to do that for each os, without github, totally useless.
Iâm starting to believe the articles about oracle moving away from java. You cant keep making things harder and expect to attract new users to the language.
The app that Iâm most familiar with deploying uses IZpack.org for Windows and Linux installers.
The windows Install has a ShortcutSpec component that the IZpack runtime can read.
(looks like doing this sort of thing on the command line can be a bit tricky to get right)
The linux install probably doesnât need IZpack at all, it just runs a set of shell scripts that manipulate XDG desktop and mime definition files, and feeds them the given installation location. Seems to work with pretty much all common linux desktop environments.
The âMainâ script freedesktop-install.sh could easily be modified to grab the current location, if you want installation to just be a matter of un-zipping in place, and running a setup script from there.
Mac does not have an âInstallationâ process as such. If the user unpacks it into their Applications folder (Which is second nature to most mac users) a properly constructed .app will have metadata that defines any mime/filetype associations. The OS automatically scans and displays such applications in all the standard locations. If the user wants desktop shortcuts, etc. they create them themselves.
--install-dir <file path>
Absolute path of the installation directory of the application on OS X or Linux. Relative sub-path of the installation location of the application such as "Program Files" or "AppData" on Windows.
So how can you give an absolute path to home dir when you dont know user?
On linux/mac how do you write paths to those or some standard directory where its common to expect write permissions are set?
You donât. jpackage seems to be trying for a system-wide installation. This would typically mean /Applications (Note the lack of tilde, as this is an absolute path. On *nix-y systems, all things accessible through the file system are on a path descended from the ârootâ / instead of from one of several drive letters, as in the windows world.) The problem with installing there is that itâs probably going to need Admin permissions to do the download/updating thing. Which it seems you would like to avoid.
For Mac:
Donât try for the application package step
Stop with the application image (The one that is a nested set of folders that starts with MyApp.app at the top)
If you donât have Xcode tools, you will not be able to sign the .app. Warn your users that they may need to allow third-party apps in their security settings.
Zip that entire directory tree. (Or, If Youâre feeling adventurous, find a windows tool that can pack it into a .dmg)
Mac user opens that up, and manually moves the .app directory (and itâs contents, but most users think that itâs a single file) to wherever they want it.
If you need a space to keep settings, downloaded assets, etc. use System.getProperty("user.home") internally
If you only need to work on parts of the app in-place, thatâs when you use the code snippet I included up-thread.
IZpack is still under development, (last commit 5 days ago) but weâve never included a JRE. (On my list to consider for future)
Yes, but youâd only be using it that way if you are trying to create a shell script. (OSX is basically a customized Unix system, so the shell languages are largely cross-compatible. Our dev/beta builds are just a zipped folder with no packaging. The Linux launch script works on macs, too.)
The only reason I want definite install locations is I want to stay away from relative paths for deleting and moving. I donât want to screw up someones system. Which is very easily done if an relative path is used in conjunction with Files.walkFileTree.
With windows, I can fully control the paths as the key variable is from the environment.
System.getenv("LOCALAPPDATA")
This makes things easy and safe, at least I feel its safer.
user.home would be just as good but I guess I will have to wait for that one.
I just thought that you could use System.getenv() since you gave that example with LOCALAPPDATA on Windows. Anyway, you can use the HOME environment variable to feed the install-dir parameter on jpackage.
Even if it requires the user to give permissions to install, where they could manually set permissions so the app would not need to ask for permissions again after they are set by the user?
I could just give instructions in that case on how to set the permissions.
Unfortunately, I dont have linux os or mac so I can figure this stuff out.
Canât you just go with .tar.gz or similar? And then maybe write a shell script to ask the users where they want it to be extracted?
I mean, the jpackage tool as it is now wonât work as we all would like it to work.
I already set gradle up so I have the option to just tar.gz and distribute.
I looked at writing scripts just to set a desktop shortcut and found something you would think was simple as that required an enormous amount of knowledge and was dangerous as hell if not done correctly.
I donât know enough about scripts to do it properly and at this stage I am thinking I will most likely concentrate on windows and if things work out, worry about other systems later.
The biggest problem for me is that I want to control exactly where the app is installed. Just like every other app that writes to disk on my windows system does. They donât give the option of where to install things that need to be updated.