我正在编译代码并生成我的桌面应用程序jar。但我无法调试代码。我想放置断点并使用Eclipse F6和F5函数逐步进行。有没有办法做到这一点?谢谢你的帮助? 我的蚂蚁脚本如下:
<project name="R - 09 - tester">
<property name="app.name" value="Tester" />
<property name="app.version" value="2.0" />
<property name="dir.root" value="C:/.../trunk" />
<property name="dir.devel" value="${dir.root}/devel" />
<property name="dir.3rdparty" value="${dir.devel}/3rdparty" />
<property name="dir.deploy" value="${dir.root}/deploy" />
<property name="dir.binary" value="${dir.deploy}/bin" />
<property name="dir.class" value="${dir.deploy}/class" />
<property name="jar.xmlbeans" value="${dir.3rdparty}/xmlbeans/xbean.jar" />
<property name="jar.modelmesi" value="${dir.binary}/Model-Mesi-2.0.jar" />
<property name="jar.mesiapi" value="${dir.binary}/Mesi-API-2.0.jar" />
<property name="jar.mesimessages" value="${dir.binary}/Mesi-Messages-2.0.jar" />
<property name="jar.javaFX" value="${dir.3rdparty}/javafx/jfxrt.jar" />
<target name="init.property">
<property name="manifest.created.by" value="..." />
<property name="manifest.implementation.title" value="...." />
<property name="manifest.implementation.vendor" value="..." />
<property name="jar.mainclass" value="main.ApplicationMain" />
<mkdir dir="${dir.class}" />
</target>
<target name="init.application" depends="init.property">
<mkdir dir="${dir.class}/${app.name}" />
<echo message="(OUTPUT) Application JAR File Name: ${app.name}-${app.version}.jar" />
</target>
<target name="clean.build" description="Clean Created Build Files" depends="init.property">
<delete dir="${dir.class}/${app.name}" />
<delete file="${dir.binary}/${app.name}-${app.version}.jar" />
</target>
<target name="clean.all" description="Clean Created All Files" depends="clean.build">
<delete dir="bin" />
<delete dir=".codepro" />
<delete dir=".sonar" />
</target>
<target name="compile.application" depends="init.application">
<!-- compile files on the src path -->
<copy file="src/SceneStyle.css" todir="${dir.class}/${app.name}"/>
<javac debug="true" srcdir="src" destdir="${dir.class}/${app.name}" debuglevel="lines,vars,source" includeantruntime="false">
<classpath>
<pathelement location="${jar.xmlbeans}" />
<pathelement location="${jar.mesiapi}" />
<pathelement location="${jar.modelmesi}" />
<pathelement location="${jar.mesimessages}" />
<pathelement location="${jar.javaFX}" />
<fileset dir="${dir.3rdparty}/jreport">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</target>
<target name="build" description="Build the Application" depends="compile.application">
<tstamp />
<!-- needed for TODAY -->
<manifestclasspath property="jar.classpaths" jarfile="${dir.binary}/${app.name}-${app.version}.jar">
<classpath>
<pathelement location="${jar.xmlbeans}" />
<pathelement location="${jar.mesiapi}" />
<pathelement location="${jar.modelmesi}" />
<pathelement location="${jar.mesimessages}" />
<pathelement location="${jar.javaFX}" />
<fileset dir="${dir.3rdparty}/jreport">
<include name="**/*.jar" />
</fileset>
</classpath>
</manifestclasspath>
<jar destfile="${dir.binary}/${app.name}-${app.version}.jar" basedir="${dir.class}/${app.name}">
<manifest>
<attribute name="Created-By" value="${manifest.created.by}" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Built-Date" value="${TODAY}" />
<attribute name="Main-Class" value="${jar.mainclass}" />
<attribute name="Class-Path" value="${jar.classpaths}" />
<attribute name="Implementation-Vendor" value="${manifest.implementation.vendor}" />
<attribute name="Implementation-Title" value="${manifest.implementation.title}" />
<attribute name="Implementation-Version" value="${app.version}-b${build.number}" />
</manifest>
</jar>
</target>
<target name="rebuild" description="Rebuild the Application" depends="clean.build,build" />
<target name="run" description="Run the Application" depends="build">
<java jar="${dir.binary}/${app.name}-${app.version}.jar"/>
</target>
答案 0 :(得分:2)
您应该使用<java>
标记启用远程调试。
<java ....>
<jvmarg value="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5555"/>
</java>
现在运行你的ant脚本。它将启动java进程并等待,直到您将调试器连接到porr 5555
。
如果您不想等到suspend=y
更改为suspend=n
。
答案 1 :(得分:0)
antscript的最终状态如下:
<target name="compile">
<javac srcdir="src" destdir="${dir.class}/${app.name}" debug="true" debuglevel="lines,vars,source" >
<classpath>
<pathelement location="..." />
</classpath>
</javac>
</target>
<target name="debug" description="Debug the Application" depends="compile">
<java jar="${dir.binary}/${app.name}-${app.version}.jar" fork="true">
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5555" />
</java>
</target>