Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Mac上分发应用程序?_Java_Xml_Windows_Macos_Netbeans - Fatal编程技术网

Java 如何在Mac上分发应用程序?

Java 如何在Mac上分发应用程序?,java,xml,windows,macos,netbeans,Java,Xml,Windows,Macos,Netbeans,当前在Mac上分发应用程序的最佳方式是什么 我想要的是一个build.xml,当它被构建(在NetBeans中)时,它将输出一个.exe(windows)和.app(mac)到dist文件夹中 我目前有一个build.xml,它将程序压缩成一个.zip文件进行分发,但我想为mac和windows添加一个.app和.exe 下面是我当前的build.xml,它输出到一个zip文件 <?xml version="1.0" encoding="UTF-8"?> <project na

当前在Mac上分发应用程序的最佳方式是什么

我想要的是一个build.xml,当它被构建(在NetBeans中)时,它将输出一个.exe(windows)和.app(mac)到dist文件夹中

我目前有一个build.xml,它将程序压缩成一个.zip文件进行分发,但我想为mac和windows添加一个.app和.exe

下面是我当前的build.xml,它输出到一个zip文件

<?xml version="1.0" encoding="UTF-8"?>
<project name="name" default="default" basedir=".">
    <description></description>
    <import file="nbproject/build-impl.xml"/>

    <property file="version.properties"/>
    <property name="version" value="${version.major}.${version.minor}.${version.patch}" />
    <property name="executable.name" value="company-${version.product.name}-${version}" />

    <target name="-post-jar" description="Generates a versioned name for the JAR file">
        <mkdir dir="LOGS" />
        <move file="dist/${ant.project.name}.jar" tofile="dist/${executable.name}.jar" />
        <antcall target="generate-run-scripts" />
        <antcall target="deliverable-osx" />
        <antcall target="deliverable-windows" />
    </target>

    <target name="generate-run-scripts" description="Generate batch files to run the application">
        <echo file="dist/run.bat">
            java -cp ${executable.name}.jar -Djava.util.logging.config.file=logging.properties -Xmx2048m -Dcom.sun.management.jmxremote classname
        </echo>
        <echo file="dist/run.sh">#!/bin/sh
            java -cp ${executable.name}.jar -Djava.util.logging.config.file=logging.properties -Xmx2048m -Dcom.sun.management.jmxremote classname
        </echo>
    </target>

    <target name="deliverable-windows" description="Deployment files for Windows runtime">
        <property name="zip.name" value="Project-${version}-windows" />
        <zip destfile="dist/${zip.name}.zip">
            <zipfileset file="dist/${executable.name}.jar" />
            <zipfileset file="logging.properties"/>
            <zipfileset dir="dist/lib" includes="*.jar" prefix="lib" />
            <zipfileset file="dist/run.bat"/>
            <zipfileset dir="LOGS" excludes="*" />
            <zipfileset dir="files" excludes="*" />
            <zipfileset file="changelog.txt"/>
        </zip>
    </target>

    <target name="deliverable-osx" description="Deployment files for Apple OS-X runtime">
        <property name="zip.name" value="Project-${version}-OSX" />
        <zip destfile="dist/${zip.name}.zip">
            <zipfileset file="dist/${executable.name}.jar" />
            <zipfileset file="logging.properties"/>
            <zipfileset dir="dist/lib" includes="*.jar" prefix="lib" />
            <zipfileset file="dist/run.sh" filemode="755" />
            <zipfileset dir="LOGS" excludes="*" />
            <zipfileset dir="files" excludes="*" />
            <zipfileset file="changelog.txt"/>
        </zip>
    </target>    
</project>

创建build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="name" default="default" basedir=".">
    <description></description>
    <import file="nbproject/build-impl.xml"/>

    <property file="version.properties"/>
    <property name="version" value="${version.major}.${version.minor}.${version.patch}" />
    <property name="executable.name" value="company-${version.product.name}-${version}" />
    <property environment="env" />

    <taskdef name="bundleapp"
             classname="com.oracle.appbundler.AppBundlerTask"   
             classpath="lib/appbundler-1.0.jar" />

    <target name="ai_debug">
        <bundleapp outputdirectory="dist"
            name="Project"
            displayname="Project-${version}"
            identifier="classname"
            mainclassname="classname">
            <runtime dir="${java.home}" />
            <classpath file="dist/Project.jar"/>
        </bundleapp>
    </target>
</project>


我将验证Java运行时是否包含在.app包中(它只是一个目录),并且在运行build.xml文件时,我会得到“Java.nio.file.NoSuchFileException:/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/Info.plist”。