Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/361.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.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 EclipseAnt:使用appbundler将.jar捆绑到.app中_Java_Eclipse_Ant_Jvm Arguments_Jarbundler - Fatal编程技术网

Java EclipseAnt:使用appbundler将.jar捆绑到.app中

Java EclipseAnt:使用appbundler将.jar捆绑到.app中,java,eclipse,ant,jvm-arguments,jarbundler,Java,Eclipse,Ant,Jvm Arguments,Jarbundler,编辑:通过使用内置jvm参数创建可执行jar,可以避免上述所有问题。创建后,我可以使用appbundler将其捆绑到.app中。如何将VM参数集成到可执行文件.jar中 我有一个可执行的jar,我必须将它捆绑到Oracle使用的.app中(以使其在OSX上工作)。如果我使用java-xstartonfirsthread-jarphotoselector.jar从终端启动jar,那么我的jar在OSX上可以完美工作。由于SWT(打包在我的可执行jar中)和Cocoa限制,我必须将-XstartO

编辑:通过使用内置jvm参数创建可执行jar,可以避免上述所有问题。创建后,我可以使用appbundler将其捆绑到.app中。如何将VM参数集成到可执行文件.jar中


我有一个可执行的jar,我必须将它捆绑到Oracle使用的.app中(以使其在OSX上工作)。如果我使用
java-xstartonfirsthread-jarphotoselector.jar
从终端启动jar,那么我的jar在OSX上可以完美工作。由于SWT(打包在我的可执行jar中)和Cocoa限制,我必须将
-XstartOnFirstThread
设置为java参数。问题是我不知道如何正确配置Eclipse(Ant!)以将双击设置为。app将使用
-XstartOnFirstThread
参数执行我的应用。以下是我的XML文件:

Build.xml

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. -->
    <project basedir="." default="build" name="PhotoSelector">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../../eclipse Java"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>
    <import file="buildMac.xml"/>
    <path id="PhotoSelector.classpath">
        <pathelement location="bin"/>
        <pathelement location="lib/swt_64_OsX.jar"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="PhotoSelector.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="Main">
        <java classname="com.selector.Main" failonerror="true" fork="yes">
            <classpath refid="PhotoSelector.classpath"/>
        </java>
    </target>
</project>
<?eclipse.ant.import?>
<project name="PhotoSelectorBundler">
<taskdef 
name="bundleapp" 
classname="com.oracle.appbundler.AppBundlerTask" 
classpath="lib/appbundler-1.0.jar" />

<target name="bundle">
<bundleapp 
    outputdirectory="dist" 
    name="PhotoSelector" 
    displayname="Photo Selector" 
    identifier="com.selector.Main"
    mainclassname="Main"
    icon="src/com/selector/256.icns">
    <classpath file="dist/PhotoSelector.jar" />
</bundleapp>
</target>
</project>

BuildMac.xml

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. -->
    <project basedir="." default="build" name="PhotoSelector">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../../eclipse Java"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>
    <import file="buildMac.xml"/>
    <path id="PhotoSelector.classpath">
        <pathelement location="bin"/>
        <pathelement location="lib/swt_64_OsX.jar"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="PhotoSelector.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="Main">
        <java classname="com.selector.Main" failonerror="true" fork="yes">
            <classpath refid="PhotoSelector.classpath"/>
        </java>
    </target>
</project>
<?eclipse.ant.import?>
<project name="PhotoSelectorBundler">
<taskdef 
name="bundleapp" 
classname="com.oracle.appbundler.AppBundlerTask" 
classpath="lib/appbundler-1.0.jar" />

<target name="bundle">
<bundleapp 
    outputdirectory="dist" 
    name="PhotoSelector" 
    displayname="Photo Selector" 
    identifier="com.selector.Main"
    mainclassname="Main"
    icon="src/com/selector/256.icns">
    <classpath file="dist/PhotoSelector.jar" />
</bundleapp>
</target>
</project>

因此,我的问题是:

  • 双击时,默认情况下如何将-XstartOnFirstThread传递给.app
  • 我必须在EclipseAnt工具中选择哪个目标才能正确导出我的.app
  • 现在my.app已创建,但会立即关闭。我使用appbundler是因为Jar Bundler不支持Java1.7(在我的项目中广泛使用)。谢谢大家!

    双击时,默认情况下如何将-XstartOnFirstThread传递给.app

    标记中添加以下内容:

    <option value="-XstartOnFirstThread"/>
    
    
    
    我必须在EclipseAnt工具中选择哪个目标才能正确导出我的.app

    我不确定你到底在问什么。大概是您的
    bundleapp
    目标。请参阅以了解分步指南

    请注意,Mac应用程序是一个扩展名为“.app”的目录。在该目录中,您将找到Contents/Info.plist文件。这将包含JVM参数和其他Java相关信息。如果你仍然有问题,这可能是一个开始调查的好地方(这也将有助于其他人回答你的问题)

    双击时,默认情况下如何将-XstartOnFirstThread传递给.app

    标记中添加以下内容:

    <option value="-XstartOnFirstThread"/>
    
    
    
    我必须在EclipseAnt工具中选择哪个目标才能正确导出我的.app

    我不确定你到底在问什么。大概是您的
    bundleapp
    目标。请参阅以了解分步指南


    请注意,Mac应用程序是一个扩展名为“.app”的目录。在该目录中,您将找到Contents/Info.plist文件。这将包含JVM参数和其他Java相关信息。如果您仍然有问题,这可能是一个开始调查的好地方(这也将有助于其他人回答您的问题)。

    效果非常好!为了让我的.app正常工作,我添加了另一行:
    (swt库的路径)。即使库被打包到我的可执行jar中,我也必须将它添加到.app中。我发现不能将JVM参数传递到可执行jar中,因为它们是命令行中的运行时选项。非常感谢。工作得很好!为了让我的.app正常工作,我添加了另一行:
    (swt库的路径)。即使库被打包到我的可执行jar中,我也必须将它添加到.app中。我发现不能将JVM参数传递到可执行jar中,因为它们是命令行中的运行时选项。非常感谢。