Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about creating AppImage for CLI Java applications #345

Open
2 of 5 tasks
SaptarshiSarkar12 opened this issue Jul 5, 2023 · 11 comments
Open
2 of 5 tasks
Labels
working on Work in progress on this issue

Comments

@SaptarshiSarkar12
Copy link
Contributor

I'm submitting a…

  • bug report
  • feature request
  • 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:
    • Maven
    • Gradle
@SaptarshiSarkar12
Copy link
Contributor Author

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

@fvarrui
Copy link
Owner

fvarrui commented Jul 6, 2023

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
Copy link
Contributor Author

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
Copy link
Owner

fvarrui commented Jul 8, 2023

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
Copy link
Contributor Author

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

@fvarrui fvarrui added the working on Work in progress on this issue label Jul 13, 2023
@SaptarshiSarkar12
Copy link
Contributor Author

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
Copy link
Owner

fvarrui commented Jul 17, 2023

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

@fvarrui
Copy link
Owner

fvarrui commented Jul 17, 2023

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
Copy link
Contributor Author

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 😅

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
working on Work in progress on this issue
Projects
None yet
Development

No branches or pull requests

2 participants