• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on Exception  RSS feed

 
Arun Bommannavar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a .jar file that I use to build my programs. I used JBuilder X to
develop this jar file (lets call it myProblem.jar). My new program test.java uses this jar file. Lets say, when I run this program an exception is thrown in the myProblem.jar as follows:

java.lang.NullPointerException
at edu.test.run(Unknown Source)
at java.lang.Thread.run(Thread.java:534)

Why is that the line number(534) in the java.lang.Thread.run is shown and not in edu.test.run? Why only Unknown Source?What do I need to do in order to see the line numbers in errors in my jar file? Any switches that I need to use while I build the jar file? If not, how?

Regards
Arun
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I do javac i get the following options.
Can you compile the classes in the myProblem.jar with -g option, jar it and run it again?

Looks like some of the stuff has been obfuscated when a javac was done without -g option.

C:\>javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-help Print a synopsis of standard options
 
Arun Bommannavar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Karthik,

Thank you. I rebuilt the jar file, rebuilt the server program and I'll wait for the error to pop up.

Regards
Arun
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arun Bommannavar:
I rebuilt the jar file, rebuilt the server program and I'll wait for the error to pop up.


Arun,

now that you have enabled the -g option (enable all debugging information), i'm not sure to what extent it is going to affect performance!. Anyways let us know if it acually helped in gtting the line number.

thanks.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arun,

now that you have enabled the '-g' option (enable all debugging information), i'm not sure to what extent it is going to affect performance!. Anyways let us know if it acually helped in getting the line number in the trace.

thanks.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote this document to answer the age-old question regarding NullPointerException:

http://www.xdweb.net/~dibblego/java/NPE.html

Note that it hasn't been updated to reflect changes in J2SE 5.0 and it hasn't been reviewed - it might help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!