本文介绍了我无法使用NetFX 11和JavaFX 12调试应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经下载了支持Java 12的Netbeans 11因此,我通过运行Maven> https:/的运行JavaFX和Netbeans Non module的Gluon网页上的步骤进行了后续操作. /openjfx.io/openjfx-docs/#next-steps

I've downloaded netbeans 11 with support for java 12So I followed up the steps from the Gluon webpage running JavaFX and Netbeans Non modular with maven > https://openjfx.io/openjfx-docs/#next-steps

我已按照说明中的说明配置了运行此应用的操作.

I have configured as showed in the instructions the action to run this app.

运行项目干净的javafx:run

Run Projectclean javafx:run

但是没有指定调试项目的任何内容.有没有办法调试这个javaFX项目?

But there is nothing specified to debug the project.Is there a way to debug this javaFX project?

中的/a>,可以将一些VM参数添加到run目标中,以便在NetBeans中调试项目. 

If you see the documentation of the javafx-maven-plugin, you can add some VM arguments to the run goal in order to debug your project in NetBeans.

但是,为了使通常的run目标准备就绪,可以仅运行项目而不进行调试,而无需注释掉添加的选项,我们可以向插件添加第二次执行.

However, to keep the usual run goal ready to just run the project and not debug, without commenting out the added options, we can add a second execution to the plugin.

像这样修改您的插件:

<plugin>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>0.0.2</version>
    <executions>
        <execution>
            <!-- Default configuration for running -->
            <id>default-cli</id>
            <configuration>
                <mainClass>com.mycompany.simonsaysgfx.App</mainClass>
            </configuration>
        </execution>
        <execution>
            <!-- Configuration for debugging -->
            <id>debug</id>
            <configuration>
                <options>
                    <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8000</option>
                </options>
                <mainClass>com.mycompany.simonsaysgfx.App</mainClass>
            </configuration>
        </execution>
    </executions>
</plugin>

现在您可以从命令行运行:

Now you can run from command line:

mvn clean javafx:run

像往常一样运行您的应用程序,并且:

to run as usual your application, and:

mvn clean javafx:run@debug

启动调试模式.然后您会看到类似以下内容的

to start debug mode. Then you will see something like:

[INFO] --- javafx-maven-plugin:0.0.2:run (debug) @ Project ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /path/to/project/target/classes
Listening for transport dt_socket at address: 8000

这时,您需要设置断点并将调试器从NetBeans -> Debug -> Attach Debugger附加到端口8000:

At this point, you need to set your breakpoints and attach a debugger from NetBeans -> Debug -> Attach Debugger to port 8000:

单击确定",您将能够调试项目.

Click OK and you will be able to debug your projects.

请注意,您还可以定义自定义NetBeans操作以使用运行"和调试"按钮.通过以下两个操作,将nbactions.xml文件添加到项目的根目录:

Note that you can also define custom NetBeans actions to use the Run and Debug buttons. Add a nbactions.xml file to the root of your project, with this two actions:

<?xml version="1.0" encoding="UTF-8"?>
<actions>
    <action>
        <actionName>run</actionName>
        <goals>
            <goal>clean</goal>
            <goal>javafx:run</goal>
        </goals>
    </action>
    <action>
        <actionName>jlink</actionName>
        <goals>
            <goal>clean</goal>
            <goal>javafx:jlink</goal>
        </goals>
    </action>
    <action>
        <actionName>debug</actionName>
        <goals>
            <goal>clean</goal>
            <goal>javafx:run@debug</goal>
        </goals>
    </action>
</actions>

现在您可以使用NetBeans运行和调试按钮.

Now you can use NetBeans run and debug buttons.

这篇关于我无法使用NetFX 11和JavaFX 12调试应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 19:25