Solved

printStackTrace...

Posted on 1998-11-17
8
177 Views
Last Modified: 2011-09-20
I have begun to use JDK1.2 and have noticed that the printStackTrace command no longer prints the line numbers for a java file.  It now prints "Compiled Code".

Can anyone help me with this?  I have listed the output from the Stack Trace below.

Thank you in advance.

Stack Trace = java.lang.Throwable
        at com.fmr.fiis.fts.util.Syslog.buildLogHeaderCompiled Code)
        at
com.fmr.fiis.fts.util.Syslog.syslog(Compiled Code)
        at
com.fmr.fiis.fts.util.Syslog.log(Compiled Code)
        at
com.fmr.fiis.fts.util.DbConnect.printDriverInfo(Compiled Code)
        at
com.fmr.fiis.fts.util.DbConnect.getDbConnection(Compiled Code)
        at
com.fmr.fiis.fts.util.FtsCore.DbInit(Compiled Code)
        at
com.fmr.fiis.fts.util.FtsCore.<init>(Compiled Code)
        at Udl3.<init>(Compiled Code)
        at Udl3.main(Compiled Code)
0
Comment
Question by:jefftk
  • 4
  • 3
8 Comments
 
LVL 7

Accepted Solution

by:
conick earned 70 total points
ID: 1227649

run the interpreter without the JIT compiler
like this:

java -Djava.compiler=NONE classname
0
 
LVL 4

Expert Comment

by:evijay
ID: 1227650
give

javac -g classname

during compilation


0
 

Author Comment

by:jefftk
ID: 1227651
OK. I will give it a try.  My question is what has changed in 1.2 to cause this problem?

Evijay,  
I have already tried your solution and it does not work.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:jefftk
ID: 1227652
Thank you Conick!  It works fine.
I do have a question, by using that option at run time what are the drawbacks.  Does the code run more slowly?  etc...
Thanks again!
0
 
LVL 7

Expert Comment

by:conick
ID: 1227653

The change in 1.2 is that the JIT (Just in Time) Compiler is defaulted to be on
In 1.1 if you had a JIT compiler (i dont believe it was included...you had to get it in a separate download) you had to specify that you were going to use it.

The JIT compiler converts the Java byte code into platform-dependent machine code so that once the app is loaded it will run faster.
So the only drawback that I can see is that it will run slower...
I only use the -D flag when debugging (and need to see the line numbers) after that there is no real reason to use the flag unless you are having problems with the JIT compiler


0
 

Author Comment

by:jefftk
ID: 1227654
Thanks.
The reason i need it is because i have created a Syslog class to log messages to a log.  I use the line numbers when printing the message so you can see exactly where in the program the message originated.
Do you know of a better way this can be done?  Does JDK1.2 have a feature like this ?
0
 
LVL 7

Expert Comment

by:conick
ID: 1227655
I dont know of any feature like that.
Although there could be one... I havent even scratched the surface
of what 1.2 can do.

You may want to catch the errors and try to use a method from the
Throwable interface (like getMessage() or toString()) to see if you
can get a String representation of the error (and grab the line numbers
from there)
Once you have a string representation you can plop that out to file



0
 

Author Comment

by:jefftk
ID: 1227656
Adjusted points to 75
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
table example 4 32
by zero exception 10 52
Android development question 2 54
ejb wildfly example 2 25
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question