不使用 NetBeans 构建 JavaFX 项目

发布于 2024-07-12 05:14:35 字数 832 浏览 4 评论 0原文

我正在尝试学习 JavaFX 并可能创建一些“学习者”游戏。 我总是在 Eclipse 中进行开发,而不是 JavaFX 团队显然试图推广的 NetBeans。

有人可以指导我如何在 Eclipse 中构建 JavaFX 项目,或者至少在不使用 NetBeans 的情况下构建 JavaFX 项目吗? 到目前为止,我发现的所有内容要么使用 NetBeans,要么在 Eclipse 中运行一个文件项目(这不适用于较大的项目)。 理想情况下,我正在寻找建立一个简单的 Ant 脚本来构建 JavaFX 项目的人,因为我认为这就是这种情况的最终结果。

我找到了下载 Eclipse JavaFX 插件。 它提供语法突出显示支持,以及一些“片段”。 我什至可以使用它来运行简单的 hello world 类型的 JavaFX 应用程序,但我似乎无法让它自动构建多文件 JavaFX 项目。 即使我可以,我似乎仍然无法编写正确的 ant 脚本来启动 JavaFX 项目。

另外,我发现这个网站讨论了如何使用javafxc Sun 创建的 Ant 任务(?),但我没有运气尝试使用他们谈论的内容。

谢谢罗斯

I'm trying to learn JavaFX and maybe create a few "learner" games. I always do my development in Eclipse, rather than NetBeans which the JavaFX team is clearly trying to push.

Can anybody point me in the direction of a how-to for building a JavaFX project in Eclipse, or at least building a JavaFX project without NetBeans? Everything I've found so far either uses NetBeans, or they're running a one-file project in Eclipse (witch won't work for larger projects). Idealy, I'm looking for somebody who's set up a simple Ant script that builds a JavaFX project, since I assume that's the end-game for this situation.

I was able to find where to download the Eclipse JavaFX plugin. It provides syntax highlighting support, plus some "snippets". I can even use it to run simple hello world type JavaFX apps, but I cant seem to get it to automatically build multi-file JavaFX projects. Even if I could, I still can't seem to write a correct ant script to jar up the JavaFX project.

Also, I found this site that talks about what you can do to use a javafxc Ant task created by Sun(?), but I'm not having any luck trying to use what they talk about.

Thanks

Ross

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

留一抹残留的笑 2024-07-19 05:14:35

如果您在 NB 中创建新项目,则会有一个名为 nbproject 的文件夹。 此文件夹包含 build-impl.xml。 该文件包含以下目标:

<target if="src.dir" name="-compile-fx">
    <taskdef classname="com.sun.tools.javafx.ant.JavaFxAntTask" classpath="${platform.bootcp}" name="javafxc"/>
    <javafxc bootclasspath="${platform.bootcp}" classpath="${build.classes.dir}:${javac.classpath}" compilerclasspath="${platform.bootcp}" debug="${javac.debug}" deprecation="${javac.deprecation}" destdir="${build.classes.dir}" excludes="${excludes}" fork="yes" includeJavaRuntime="false" includeantruntime="false" includes="**/*.fx" source="${javac.source}" sourcepath="" srcdir="${src.dir}" target="${javac.target}">
        <compilerarg line="${javac.compilerargs}"/>
    </javafxc>
</target>

这是为 Eclipse 创建 ant 的良好开端。 我不确定 Eclipse 的构建方式如何,但可能存在限制。 com.sun.tools.javafx.ant.JavaFxAntTask 位于 SDK 中,而不是编译器 jar 中。 祝你好运!。

If you create new project in NB there is folder called nbproject. This folder contains build-impl.xml. This file contains this target:

<target if="src.dir" name="-compile-fx">
    <taskdef classname="com.sun.tools.javafx.ant.JavaFxAntTask" classpath="${platform.bootcp}" name="javafxc"/>
    <javafxc bootclasspath="${platform.bootcp}" classpath="${build.classes.dir}:${javac.classpath}" compilerclasspath="${platform.bootcp}" debug="${javac.debug}" deprecation="${javac.deprecation}" destdir="${build.classes.dir}" excludes="${excludes}" fork="yes" includeJavaRuntime="false" includeantruntime="false" includes="**/*.fx" source="${javac.source}" sourcepath="" srcdir="${src.dir}" target="${javac.target}">
        <compilerarg line="${javac.compilerargs}"/>
    </javafxc>
</target>

This is good start to create ant for Eclipse. I'm not sure how building works for Eclipse, but there could be limitations. The com.sun.tools.javafx.ant.JavaFxAntTask is located in SDK, not in compiler jar. Good luck!.

鹿港巷口少年归 2024-07-19 05:14:35

我读过有关 JavaFX 的文章,其中有一个可用的 Eclipse 扩展。 根据该文章,它不像 NetBeans 对 FX 的支持那么成熟,但应该比没有好......

I have read in article about JavaFX that there is an Eclipse extension available for it. According to that article it is not as mature as NetBeans support for FX but should be better than nothing...

烟燃烟灭 2024-07-19 05:14:35

我已经为构建过程创建了部分 Ant 脚本。 我可以看出它实际上是在编译 JavaFX 类并将它们打包。 但是,我认为缺少一个 Ant 任务,在该任务中我创建了 Applet 中所需的 JNLP 对象,而我也缺少该对象(但设法伪造)。

因为我没有明确说明,所以我没有让它进入工作状态,所以不要指望仅仅通过做我所做的事情就可以到达那里;)

这个Ant脚本是我所知道的已经得到了。 为了简洁起见,我省略了除了重要部分之外的所有内容...

<project name="RABfx" default="all" basedir=".">
    ... 
    <property environment="env"/>
    <property name="java.home" value="${env.JAVA_HOME}" />
    <property name="jfx.home" value="${env.JAVAFX_HOME}" />
    <path id="compile.classpath">
        <fileset dir="${java.home}/lib">
            <include name="**/*.jar" />
        </fileset>
        <fileset dir="${jfx.home}/lib">
            <include name="**/*.jar" />
        </fileset>
        ...
    </path>

    <taskdef classname="com.sun.tools.javafx.ant.JavaFxAntTask" name="javafxc">
        <classpath refid="compile.classpath" />
    </taskdef>

    ...

    <target name="compile">
        <javac srcdir="${src}" destdir="${src.classes}" includes="**/*.java">
            <classpath refid="compile.classpath" />
        </javac>
        <javafxc srcdir="${src}" destdir="${src.classes}" includes="**/*.fx" executable="${jfx.home}/bin/javafxc.exe">
            <classpath refid="compile.classpath" />
        </javafxc>
        ...
    </target>

    <target name="build">
        <jar jarfile="${src.jar}">
            <fileset dir="${src.classes}" />
        </jar>
    </target>
    ...
</project>

另外,我的“伪造”小程序...

...
<script src="http://dl.javafx.com/dtfx.js"></script>
<script>
    javafx(
        {
            archive: "RABfx.jar",
            width: 440,
            height: 560,
            code: "TicTacToe.Main",
            name: "TicTacToe"
        }
    );
</script>
...

I've created a partial Ant script for the build process. I can tell that it's actually compiling the JavaFX classes and Jaring them up. However, I think I'm missing an Ant task where I create the JNLP object that is needed in the Applet that I'm also missing (but managed to fake).

Since I didn't explicitly state it, I did not get this to a working state, so don't expect to get there just by doing what I did ;)

This Ant script is as far as I've gotten. I've left out everything but the important parts for brevity...

<project name="RABfx" default="all" basedir=".">
    ... 
    <property environment="env"/>
    <property name="java.home" value="${env.JAVA_HOME}" />
    <property name="jfx.home" value="${env.JAVAFX_HOME}" />
    <path id="compile.classpath">
        <fileset dir="${java.home}/lib">
            <include name="**/*.jar" />
        </fileset>
        <fileset dir="${jfx.home}/lib">
            <include name="**/*.jar" />
        </fileset>
        ...
    </path>

    <taskdef classname="com.sun.tools.javafx.ant.JavaFxAntTask" name="javafxc">
        <classpath refid="compile.classpath" />
    </taskdef>

    ...

    <target name="compile">
        <javac srcdir="${src}" destdir="${src.classes}" includes="**/*.java">
            <classpath refid="compile.classpath" />
        </javac>
        <javafxc srcdir="${src}" destdir="${src.classes}" includes="**/*.fx" executable="${jfx.home}/bin/javafxc.exe">
            <classpath refid="compile.classpath" />
        </javafxc>
        ...
    </target>

    <target name="build">
        <jar jarfile="${src.jar}">
            <fileset dir="${src.classes}" />
        </jar>
    </target>
    ...
</project>

Also, my "faked" Applet...

...
<script src="http://dl.javafx.com/dtfx.js"></script>
<script>
    javafx(
        {
            archive: "RABfx.jar",
            width: 440,
            height: 560,
            code: "TicTacToe.Main",
            name: "TicTacToe"
        }
    );
</script>
...
浅语花开 2024-07-19 05:14:35

在我提出这个问题之后,官方(我认为?)Eclipse 的 JavaFX 插件发布了。 转至 JavaFX for Eclipse 页面。 我安装了该插件,一切都自动工作了!

After I asked this question, an official (I think?) JavaFX plugin for Eclipse was released. Go to the JavaFX for Eclipse page. I installed the plugin and everything automagically worked!

尘曦 2024-07-19 05:14:35

要么使用前面提到的 JavaFxAntTask,要么在 NetBeans 中生成项目并在 Eclipse 中打开它,然后就可以运行 Ant 目标了。 或者等待 1.1,它有望提供完整的 Eclipse 和 IDEA 支持。

Either use the JavaFxAntTask mentioned before or generate the project in NetBeans and open it in Eclipse and then you can just run Ant targets. Or wait for 1.1 which will hopefully come with full Eclipse and IDEA support.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文