Question about creating AppImage for CLI Java applications
I'm submitting a…
- [ ] bug report
- [ ] feature request
- [X] other
Short description of the issue/suggestion:
I want to build an AppImage of Drifty CLI, a CLI version of Drifty which requires terminal as an interface between the application and the user. But, the AppImage created by JavaPackager plugin for the CLI, does not open the Application in terminal mode. What property should I set in the pom.xml such that my objectives fulfill?
What is the expected behavior?
A CLI Application to be created, which when run by the user, starts the Java app with terminal as the only interface.
What is the motivation / use case for changing the behavior?
This feature if not already present, will help in distributing terminal based Java applications.
Please tell us about your environment:
- JavaPackager version: 1.7.2
- OS version: Ubuntu-22.10
- JDK version: 20.0.1
- Build tool:
- [X] Maven
- [ ] Gradle
@fvarrui Another issue to look into. I think this feature is not already present.
Hi @SaptarshiSarkar12!
Let's see if I understand correctly, when running Drifty CLI from menu, does it have to open a terminal window and run your app on it?
Right now, you just have to open a terminal and run your AppImage binary, passing any necessary arguments.
Hi @SaptarshiSarkar12!
Let's see if I understand correctly, when running Drifty CLI from menu, does it have to open a terminal window and run your app on it?
Right now, you just have to open a terminal and run your AppImage binary, passing any necessary arguments.
Yeah @fvarrui , you understood correctly. When the user double-click and run the Drifty CLI AppImage, the terminal does not pop up.
And my question is that is there any way to tell the AppImage builder to enable Terminal and run the app in it?
Like in the below image, an example of a velocity template file contains a line Terminal=false. So, can this .vtl files help to fulfill my objective (to open the app in terminal)?
Here is the link to the above file - https://github.com/fvarrui/JavaPackager/blob/master/src/main/resources/linux/desktop.vtl .
The right .desktop files template for AppImages is https://github.com/fvarrui/JavaPackager/blob/master/src/main/resources/linux/desktop-appimage.vtl.
I'm trying something like this:
Exec=x-terminal-emulator -e "${info.name} %U"
Terminal=true
This will run your CLI app inside your default terminal emulator ... or at least, I think so. I keep testing!
PS: you can create and use your own custom templates (link)
ok, let me try in my local environment. Thank you @fvarrui !
The right .desktop files template for AppImages is https://github.com/fvarrui/JavaPackager/blob/master/src/main/resources/linux/desktop-appimage.vtl.
I'm trying something like this:
Exec=x-terminal-emulator -e "${info.name} %U" Terminal=trueThis will run your CLI app inside your default terminal emulator ... or at least, I think so. I keep testing!
PS: you can create and use your own custom templates (link)
@fvarrui The command x-terminal-emulator -e "${info.name} %U" doesn't work i.e. the AppImage does not open itself in terminal mode.
@SaptarshiSarkar12 I'm still doing tests, but I think it's the way to go
JP uses a BASH script as executable (JAR file is concatenated to this script as a payload), and maybe we can change the startup.sh.vtl template to accept --terminal argument to run itself again with x-terminal-emulator, so this change will be available not only for AppImage, but for DEB, RPM, zipball, tarball too. I then we can run our app on a terminal from desktop file using ${info.name} --terminal %U.
I'm not really sure if this could have side effects and if it's really a good idea. What do you think?
PRs are welcome 😅
JP uses a BASH script as executable (JAR file is concatenated to this script as a payload), and maybe we can change the
startup.sh.vtltemplate to accept--terminalargument to run itself again withx-terminal-emulator, so this change will be available not only for AppImage, but for DEB, RPM, zipball, tarball too. I then we can run our app on a terminal from desktop file using${info.name} --terminal %U.I'm not really sure if this could have side effects and if it's really a good idea. What do you think?
PRs are welcome :sweat_smile:
Yeah, it's pretty good Idea. Let me have a look in the project and understand it. @fvarrui . If possible, I might open a PR for this.
JP uses a BASH script as executable (JAR file is concatenated to this script as a payload), and maybe we can change the
startup.sh.vtltemplate to accept--terminalargument to run itself again withx-terminal-emulator, so this change will be available not only for AppImage, but for DEB, RPM, zipball, tarball too. I then we can run our app on a terminal from desktop file using${info.name} --terminal %U.I'm not really sure if this could have side effects and if it's really a good idea. What do you think?
PRs are welcome sweat_smile
Hey @fvarrui, I have checked your GitHub discussions #292 and have found that jpackage has options to generate installers for CLI apps (like --win-console option for windows OS CLI apps). So, I think adding support for jpackage might help for this issue even.
I have added some links and facts in #292 , check them out. They might be of help.