fvarrui / JavaPackager

:package: Gradle/Maven plugin to package Java applications as native Windows, MacOS, or Linux executables and create installers for them.
GNU General Public License v3.0
1.03k stars 130 forks source link

Question about creating AppImage for CLI Java applications #345

Open SaptarshiSarkar12 opened 1 year ago

SaptarshiSarkar12 commented 1 year ago

I'm submitting a…

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:

SaptarshiSarkar12 commented 1 year ago

@fvarrui Another issue to look into. I think this feature is not already present.

fvarrui commented 1 year ago

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.

SaptarshiSarkar12 commented 1 year ago

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)? image Here is the link to the above file - https://github.com/fvarrui/JavaPackager/blob/master/src/main/resources/linux/desktop.vtl .

fvarrui commented 1 year ago

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)

SaptarshiSarkar12 commented 1 year ago

ok, let me try in my local environment. Thank you @fvarrui !

SaptarshiSarkar12 commented 1 year ago

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)

@fvarrui The command x-terminal-emulator -e "${info.name} %U" doesn't work i.e. the AppImage does not open itself in terminal mode.

fvarrui commented 1 year ago

@SaptarshiSarkar12 I'm still doing tests, but I think it's the way to go

fvarrui commented 1 year ago

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 😅

SaptarshiSarkar12 commented 1 year ago

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 :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.

SaptarshiSarkar12 commented 1 year ago

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 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.

SaptarshiSarkar12 commented 1 year ago

I have added some links and facts in #292 , check them out. They might be of help.