Solved

printStackTrace...

Posted on 1998-11-17
8
175 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java  and programming certification ? 4 86
eclipse java  build path 6 43
Java JRE greater than 1.6 5 50
eclipse shortcuts 9 45
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

911 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now