Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

printStackTrace...

Posted on 1998-11-17
8
Medium Priority
?
183 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 280 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
Industry Leaders: 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!

 

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

610 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