Breakpoints in Java file not getting detected during ANT Build

I am having a code like one below.

package com.mugil.servlet2;

public class Sample
{
    static
    {
      System.out.println("Hi There");
    }


    public static void main(String[] args) 
    {
      System.out.println("Sample Output1");
      System.out.println("Sample Output2");
    }
}

I am initiating a ANT build script by the script below

<?xml version="1.0" encoding="UTF-8"?>
<project name="ANT2" default="copyTarget">
  <target name="copyTarget">
  <mkdir dir="test/classes/"/>
  <javac srcdir="src/com/mugil/servlet2/" destdir="test/classes/" includeantruntime="false"></javac>
    <java classname="com.mugil.servlet2.Sample">
    <classpath path="test/classes/"></classpath>
     </java>
   </target>
</project>

I have added debugger at first line of static block and in main block enter image description here

When I do the ANT build I am unable to have control in Java Breakpoints.

Thanks for Reply.

Jon Skeet
people
quotationmark

Breakpoints don't exist in Java source code at all - nor even in the compiled class files. They're purely a debug-time feature - the debugger instructs the VM where the breakpoints are. The breakpoints you're seeing in your IDE are stored in an IDE-specific fashion; they're not expected to be persisted with the source code.

What does matter in terms of compile-time information is the line numbers - if you don't include those in the class file, then clearly any line-based breakpoints can't be installed when you try to debug the code.

people

See more on this question at Stackoverflow