简体   繁体   中英

How to change java default icon of installer in java for mac installer

I have javafx application, I have successfully created the installer of application, but I want to change the java default icon of installer, So I have added ${basedir}/src/main/resources/images/logoIcon.ico in pom.xml but it can not change,

The entire snap of pom.xml as follows:

http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.testDemo</groupId>
<artifactId>test-app</artifactId>
<name>demo-app</name>

<packaging>jar</packaging>
<version>1.0</version>

<organization>
    <!-- Used as the 'Vendor' for JNLP generation -->
    <name>testDemo</name>
</organization>

<properties>
    <slf4j.version>1.6.1</slf4j.version>
    <springframework.version>3.2.2.RELEASE</springframework.version>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>com.zenjava</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>1.5</version>
            <configuration>

                <mainClass>com.testdemo.testapp.testApplication</mainClass>

                <!-- only required if signing the jar file -->
                <keyStoreAlias>example-user</keyStoreAlias>
                <keyStorePassword>example-password</keyStorePassword>
                <permissions>
                    <permission>all-permissions</permission>
                </permissions>
                <icon>${basedir}/src/main/resources/images/logoIcon.ico</icon>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>

    </plugins>
</build>


<dependencies>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${springframework.version}</version>
    </dependency>

    <dependency>
        <groupId>com.miglayout</groupId>
        <artifactId>miglayout-javafx</artifactId>
        <version>4.2</version>
    </dependency>

    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${slf4j.version}</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${slf4j.version}</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${slf4j.version}</version>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>

    <dependency>
        <groupId>commons-beanutils</groupId>
        <artifactId>commons-beanutils-core</artifactId>
        <version>1.8.3</version>
    </dependency>

    <dependency>
        <groupId>com.javadocmd</groupId>
        <artifactId>simplelatlng</artifactId>
        <version>RELEASE</version>
    </dependency>

    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.2.7</version>
    </dependency>

    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.2.6</version>
    </dependency>

    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20090211</version>
    </dependency>

</dependencies>

and for creating package, I use following commands,

  1. mvn jfx:build-jar(it gives only jar of application)
  2. mvn jfx:build-native (it gives .dmg file of application)

So please suggest me, how to change default installer icon for mac.

I added src/main/deploy/package/macosx/myapp.ico there and it finally worked :)

For you:

Create src/main/deploy/package/macosx/ folder Add icon with name ${project.build.finalName}.ico Run mvn jfx:build-native I haven't played with it extensively - just got it to work and wanted to share. So if you want to use icon with different name, I don't know how. Not yet at least. The ... section in the config section seems to be for webstart, so I haven't been using it. Hope you get it to work!

Answered same at How to set custom icon for javafx native package icon on Windows

A quick look at source code make me think that the icon cannot be in a subdirectory (it seems to be a bug).

As a workaround, you can try to move your logoIcon.ico one directory upper (in src/main/resources )

If it doesn't work, you can also try to put it in src/main/deploy/ (and not in a subdirectory)

To debug it, you can also run maven with the -X option and looking for the log:

Using icon file at ...

But be careful with this log since it will probably print the correct path while it seems that only the filename will be used to resolve the icon (ie sub dirs will be ignored)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM