Solved

printStackTrace...

Posted on 1998-11-17
8
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

737 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