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

After turning on administrator Required, there is no response after entering the password when starting under mac. #398

Open futurecad opened 5 months ago

futurecad commented 5 months ago

I'm submitting a…

Short description of the issue/suggestion:

Steps to reproduce the issue/enhancement:

  1. [First Step]
  2. [Second Step]
  3. [Other Steps...]

What is the expected behavior? After turning on administrator Required, there is no response after entering the password when starting under mac.

What is the current behavior? Turn on administrator Required and then double-click the package program but it cannot run after entering the password.

Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement?

What is the motivation / use case for changing the behavior? I need to start this app as administrator

Please tell us about your environment: macos14.4 jdk21 javapackager1.7.5

Other information (e.g. related issues, suggestions how to fix, links for us to have context)

fvarrui commented 5 months ago

Hi @futurecad! I've just try it and managed to reproduce your issue. Not sure why, but it seems that universalJavaApplicationStub script it's not being copied in Contents/MacOS, just the auxiliary script startup, used to run as administrator. I'll try to figure out whats happening asap. Thanks for taking your time posting this issue.

fvarrui commented 5 months ago

Ok, I've just found where's the bug:

https://github.com/fvarrui/JavaPackager/blob/f01e4f0d5e89e70c3a31181cc1a9aeee445a0919/src/main/java/io/github/fvarrui/javapackager/packagers/MacPackager.java#L123-L150

Some time ago a new feature which let use a custom launcher script was introduced ... creating this side effect. As you can see here, the startup script should be an extension, not an alternative to universalJavaApplicationScript or the custom one.

fvarrui commented 5 months ago

Just released a SNAPHOT version to Maven Central: 1.7.6-20240330.174335-4. Please, test it and give me some feedback. Thanks!

You can take a look about how to use snapshot versions.

futurecad commented 5 months ago

I used 1.7.6 - SNAPSHOT version and still have the same problem. After double-clicking the package to run and entering the password, there is still no prompt. macos version: 14.4.1 (23 E224)

fvarrui commented 5 months ago

I used 1.7.6 - SNAPSHOT version and still have the same problem. After double-clicking the package to run and entering the password, there is still no prompt. macos version: 14.4.1 (23 E224)

Ok, I'm not sure what's happening right now.

Please, could you try to run your app from the terminal using $ ./Your.app/Contents/MacOS/startup and universalJavaApplicationStub?

futurecad commented 5 months ago

Also doesn't work. How can I show you the relevant logs?

futurecad commented 5 months ago

Are you solving this problem now?

fvarrui commented 5 months ago

Hi @futurecad!

Yes, but I haven't found a solution yet. I'll tell you something if figure out what's happening.

You can find some logs in Console.app

fvarrui commented 5 months ago

Hi @futurecad! Sorry, I can't figure out what's happening since this was working fine some time ago. Let me know if you find a different way than calling osascript to run something as admin on macOS. I'll keep researching about this issue.

futurecad commented 3 months ago

1.7.6 - SNAPSHOT Another problem

Null reference [template 'mac/startup.vtl', line 4, column 48]: $SCRIPTPATH cannot be resolved. [DEBUG] ResourceManager: found mac/Info.plist.vtl with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader [DEBUG] Null reference [template 'mac/Info.plist.vtl', line 47, column 33]: $APP_PACKAGE cannot be resolved.

futurecad commented 3 months ago

I received printouts in my in-application logs but did not successfully start the gui interface.

futurecad commented 3 months ago

The program can be started normally through startup, but it needs to be set - Djava.awt.headless=false \ Launched via app without any logs

fvarrui commented 2 months ago

The program can be started normally through startup, but it needs to be set - Djava.awt.headless=false Launched via app without any logs

Hi @futurecad! Did you find a solution?

futurecad commented 2 months ago

The program can be started normally through startup, but it needs to be set - Djava.awt.headless=false Launched via app without any logs

Hi @futurecad! Did you find a solution?

not yet

AridanWarlock commented 2 weeks ago

Hi, i have same problem. I tried download "issue-398" branch in mavenLocal, but "javapackager" plugin in Gradle doesn`t work. Also i tried SNAPSHOT-1.7.6-20240330.174335-4, but i have same reaction on "isAdministratorRequired = true".

Can you load this in another SNAPSHOT please?

fvarrui commented 2 weeks ago

Hi @futurecad and @AridanWarlock! Sorry, but my availability has been very limited lately and I no longer have a Mac to be able to do tests.

Hi, i have same problem. I tried download "issue-398" branch in mavenLocal, but "javapackager" plugin in Gradle doesn`t work.

Do you mean it cannot be built? Which tool versions are you using?

Also i tried SNAPSHOT-1.7.6-20240330.174335-4, but i have same reaction on "isAdministratorRequired = true". Can you load this in another SNAPSHOT please?

I'm sorry, snapshot versions are not available forever, but just released a new one for this issue: 1.7.6-20240901.181942-1

The program can be started normally through startup, but it needs to be set - Djava.awt.headless=false Launched via app without any logs

I wonder if that the app finally starts with administrator privileges using -Djava.awt.headless=false. If so, you can use vmArgs property to set this argument at runtime by default.

AridanWarlock commented 2 weeks ago

Hi @fvarrui! I set new SNAPSHOT and add -Djava.awt.headless=false. Now I have both scripts created, but still "startup" immediately closes without waiting for the password to be entered.

Снимок экрана 2024-09-04 в 13 51 30
AridanWarlock commented 1 week ago

Hi, @fvarrui! Any ideas what went wrong? What should I try to do?

fvarrui commented 1 week ago

Hi, @fvarrui! Any ideas what went wrong? What should I try to do?

Hi @futurecad! Do you know any way to call a script on MacOS as admin without using osascript?

fvarrui commented 1 week ago

Maybe it would be posible to create a native launcher (for x86 and/or aarch64) which asks for user credentials and runs universalJavaAplicationScript as admin?

futurecad commented 1 week ago

@AridanWarlock @fvarrui I couldn't find a better startup solution, so I had to change the program to pop up the user password to temporarily circumvent this problem.