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

Generated .exe does nothing #237

Open
ppazos opened this issue Feb 27, 2024 · 8 comments
Open

Generated .exe does nothing #237

ppazos opened this issue Feb 27, 2024 · 8 comments

Comments

@ppazos
Copy link

ppazos commented Feb 27, 2024

I'm doing this for packaging a CLI app on Linux with the windows target:

export WIN_JAVA_HOME=/home/pablo/GitHub/jdk-11.0.22+7-win
java -jar packr-all-4.0.0.jar --platform windows64 --jdk $WIN_JAVA_HOME --useZgcIfSupportedOs --executable norapp --classpath app/build/libs/cabolabs-x-all.jar --mainclass com.cabolabs.automation.App --output out-win

In the out-win folder I have a .exe, when I try to execute it in a win virtual machine I get no output.

Though if I execute the jar directly: out-win\jre\bin\java -jar cabolabs-x-all.jar it works as expected.

I can't tell what's wrong with the .exe generated. There is no output at all, even from the cmd console.

Thanks!

@ppazos
Copy link
Author

ppazos commented Feb 27, 2024

This is the system info from the win VM

Screenshot_2024-02-27_02-11-19

@Frosty-J
Copy link
Contributor

Same results if you remove --useZgcIfSupportedOs? Seems unlikely to be the cause, but I'm stumped. Make sure it's a 64-bit JRE.you're using.

While libGDX in VirtualBox is usually a bad time (the highest OpenGL I've got out of it is 1.1, libGDX requiring 2.0 or gdx-angle-lwjgl3) that should be okay in your case since the JAR works. Java output gets redirected to the command line, so you'd know if it was getting that far.

@ppazos
Copy link
Author

ppazos commented Feb 27, 2024

@Frosty-J let me check.

My application is CLI, I don't care much about OpenGL stuff. I only use the VM because I don't have a windows box, just linux here.

@ppazos
Copy link
Author

ppazos commented Feb 27, 2024

@Frosty-J after testing it's doing something strange.

  1. I tried to execute the exe directly to double check the error wasn't in the app using this CLI,
  2. it seems the exe is executed then closed,
  3. then suddenly the output of the command just appears on the windows cmd,
  4. then the prompt is blocked there,
  5. when I hit enter it seems to finish and gets back to prompt.

So when I execute that exe from a nodejs app, I don't get the proper output, it's like I execute an app, then that app executes other app, and I need the output of that one (that's the one executed by java -jar xxx.jar).

You can see what I mean in this gif

Recording 2024-02-27 at 16 30 09

@ppazos
Copy link
Author

ppazos commented Feb 27, 2024

If I run the jar directly I get the correct behavior:

  1. the response of the command is written right away in the console
  2. there is no strange behavior on closing then seeing the output
  3. the prompt is returned right away

Screenshot_2024-02-27_18-41-11

Since I'm kind of in a hurry, I'll remove the exe and run the jar directly until there is some solution. Thanks!

@Frosty-J
Copy link
Contributor

Packr returning control to the Windows command line is normal, despite the Java application's output also going there. It's possible it isn't well-suited to this; might want to try jpackage for shipping a JRE with your tool.

@ppazos
Copy link
Author

ppazos commented Feb 27, 2024

@Frosty-J if it returns control without executing the jar on that thread, then it's unsuitable to actually run any CLI program. On Linux it seems to run the jar in the same thread it runs the generated executable.

I can't use jpackage since I'm on JDK11, IIRC jpackage is JDK14.

I'm still checking on how to do the macOS builds, but do you know if macOS executables behave like the linux ones or like the win ones?

Thanks

@Frosty-J
Copy link
Contributor

I don't know, so I'm not going to make any claims, but I predict it would behave like Linux on macOS, being Unix. I don't know how well it will work on the Apple Silicon Macs, since Packr is x64-only.

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

No branches or pull requests

2 participants