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.07k stars 134 forks source link

demo.app created for mac os dose not start properly. #233

Closed kia closed 2 years ago

kia commented 2 years ago

I'm submitting a…

Short description of the issue/suggestion: demo.app created for mac os dose not start properly.

Steps to reproduce the issue/enhancement:

  1. create simple java application
  2. use the JavaPackager maven plugin to create a package for mac os
  3. start the demo.app by double click on the created icon in finder or use open demo.app on cli

What is the expected behavior? doubble-click on the created app icon or starting the app with open demo,app on cli the app starts. The runnable.jar file is working as expected: java -cp libs -jar demo-runnable.jar starts properly.

What is the current behavior? By trying to start the app with open demo.app the following error message occurs: LSOpenURLsWithRole() failed with error -10810 for the file demo.app.

Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement? I created a demo project. see demo.zip

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

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

demo.zip

kerner1000 commented 2 years ago

Hi @kia, can you re-try with <codesignApp>false</codesignApp> in the Mac settings and see if that makes a difference?

kia commented 2 years ago

Hi @kerner1000 . I tried it with the flag you suggested. With no change. The issue is still there. Here is the output of the maven plugin during packaging:

Creating app ...
[INFO]     Initializing packager ...
[INFO]         PackagerSettings [outputDirectory=/Users/maven/jenkins/workspace/jdk17-fx-issue/target/deploy/osx, licenseFile=null, iconFile=null, generateInstaller=true, forceInstaller=false, mainClass=de.softquadrat.demo.hello.HelloApplication, name=demo, displayName=demo, version=1.0-SNAPSHOT, description=demo, url=http://www.datasqill.de/, administratorRequired=false, organizationName=ACME, organizationUrl=, organizationEmail=null, bundleJre=true, customizedJre=false, jrePath=null, jdkPath=/Users/remote/java/jdk-17.0.3+7/Contents/Home, additionalResources=[], modules=[], additionalModules=[], platform=mac, envPath=null, vmArgs=[], runnableJar=null, copyDependencies=true, jreDirectoryName=jre, winConfig=null, linuxConfig=null, macConfig=MacConfig [icnsFile=null, backgroundImage=null, windowWidth=517, windowHeight=270, windowX=10, windowY=60, iconSize=128, textSize=12, iconX=120, iconY=135, appsLinkIconX=400, appsLinkIconY=135, volumeIcon=null, volumeName=null, generateDmg=true, generatePkg=true, relocateJar=true, appId=de.softquadrat.demo.hello.HelloApplication, developerId=-, entitlements=null, codesignApp=false, infoPlist=InfoPlist [additionalEntries=, bundlePackageType=BNDL]], createTarball=true, createZipball=false, extra=null, useResourcesAsWorkingDir=true, assetsDir=/Users/maven/jenkins/workspace/jdk17-fx-issue/src/main/deploy/package, classpath=null, jreMinVersion=null, manifest=null, additionalModulePaths=[], fileAssociations=[], packagingJdk=/Users/remote/java/jdk-17.0.3+7/Contents/Home, scripts=Scripts [bootstrap=null, preInstall=null, postInstall=null]]
[INFO]     Packager initialized!
fvarrui commented 2 years ago

Try with 1.6.7. It seems a problem of missing entitlements. This new version generates default entitlements. Feedback please. Thanks!

fvarrui commented 2 years ago

I'm going to be away from home for a few days, so I can't test your demo app until then

kia commented 2 years ago

now I see the following message:

Some files were not found for the file /Users/remote/demo-1.6.7/demo.app.

fvarrui commented 2 years ago

This last problem could be related to #239

kia commented 2 years ago

Thank you @fvarrui . The app starts now if I execute the universalJavaApplicationStub- executable itself on the console but not by double click on the app-icon nor by open universalJavaApplicationStub.

fvarrui commented 2 years ago

Ok, can you check the syslog (Console.app)? universalJavaApplicationStub script logs info and errors there.

treimers commented 2 years ago

I think I found something that might solve this issue.

The call to launch in main-method was commented out. According to this example launch should be called in main.

With

public static void run(String[] args) {
    launch(args);
}

it is running in my environment.

@Kia: Can you please verify? Thanks!

Note that I ran into issue https://github.com/fvarrui/JavaPackager/issues/239 and downgraded to JavaPackager 1.6.6 which worked fine for me.

fvarrui commented 2 years ago

I'm going to be away from home for a few days, so I can't test your demo app until then

Hi @kia! (and @treimers 😄)

Sorry for being late in providing a solution, but after upgrading my Windows system from 10 to 11, my Mac OS VM stops working! Time is playing against me right now ... lots of cauldrons on fire 😞

The problem reported in #239 is fixed in 1.7.0-SNAPSHOT (available in devel branch).

Plaese, try what @treimers suggests!

treimers commented 2 years ago

Hi all,

looks that we all three are on vacation currently 😄

I managed to get it running using different JDKs with small changes:

  1. Java Code: I created a new Launcher class and moved the main method to that class (according to this article using the wildly irresponsible cowboy fix).
  2. pom: I downgraded the JFX libs to 11 in order to test with different Java versions.

I tested successfully with following JDKs in my environment:

17.0.4, x86_64: "OpenJDK 17.0.4"    /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home
17.0.3, x86_64: "Zulu 17.34.19" /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home
15.0.7, x86_64: "Zulu 15.40.19" /Library/Java/JavaVirtualMachines/zulu-15.jdk/Contents/Home
15, x86_64: "AdoptOpenJDK 15"   /Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home
14.0.1, x86_64: "AdoptOpenJDK 14"   /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home
11.0.6, x86_64: "AdoptOpenJDK 11"   /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home

Here the modified project: demo_treimers.zip

@kia we can discuss this next week when you are back. Enjoy!

kia commented 2 years ago

Using 1.6.6 with the suggestion of @treimers it works fine.