This discussion is archived
3 Replies Latest reply: Feb 16, 2008 7:34 AM by baftos RSS

Find the line number of a method call?

807603 Newbie
Currently Being Moderated
When I am using netbeans and an exception is thrown, the stack trace will know the line number of the method call. Is this behavior part of netbeans or can I find out what line of a .java file the method was called from?

Thanks for any help.
  • 1. Re: Find the line number of a method call?
    baftos Expert
    Currently Being Moderated
    I think trying it would be faster than typing the question.
    If you are not used to executing a java program outside netbeans,
    I strongly recommend you learn it now.
    For me, it would have been easier to answer yes or no than typing
    all this, but it's sincere advice.
  • 2. Re: Find the line number of a method call?
    807603 Newbie
    Currently Being Moderated
    baftos wrote:
    I think trying it would be faster than typing the question.
    If you are not used to executing a java program outside netbeans,
    I strongly recommend you learn it now.
    For me, it would have been easier to answer yes or no than typing
    all this, but it's sincere advice.
    any chance you could give me some hints?

    To run it outside of netbeans I think i can use java and javac, something along the lines of
    cd /directory/where/classes/are
    javac *.java
    java main
    where main is the class i want to run, but when i do this the javac stage fails with errors.
    Though the errors do seem to contain line numbers, so possibly my question has been partially answered?
  • 3. Re: Find the line number of a method call?
    baftos Expert
    Currently Being Moderated
    Benpage26 wrote:
    baftos wrote:
    I think trying it would be faster than typing the question.
    If you are not used to executing a java program outside netbeans,
    I strongly recommend you learn it now.
    For me, it would have been easier to answer yes or no than typing
    all this, but it's sincere advice.
    any chance you could give me some hints?

    To run it outside of netbeans I think i can use java and javac, something along the lines of
    cd /directory/where/classes/are
    javac *.java
    java main
    where main is the class i want to run, but when i do this the javac stage fails with errors.
    Though the errors do seem to contain line numbers, so possibly my question has been partially answered?
    Build in Netbeans the way you usually do.
    At the end of the build Netbeans displays something like this:

    To run this application from the command line without Ant, try:
    java -jar "something.jar"

    Do so.

    Edited by: baftos on Feb 16, 2008 10:33 AM