Tolgar
asked on
How to debug a java code using jdb on command line?
Hi,
I have a jar file which I created using maven from my source code. How can I debug this jar file using jdb on the command line?
Thanks,
I have a jar file which I created using maven from my source code. How can I debug this jar file using jdb on the command line?
Thanks,
Waht is your goal? Please, elaborate.
If you have source codes there are definitely easier ways to do it
If you have source codes there are definitely easier ways to do it
ASKER
Well, I have my java code. For my application I create jar file from this code using maven and this code also uses some other external jar while creating the jar. Then my Perl code run and call this jar file with some input arguments.
So this is the first part of the story.
Now, I wanna pass these input arguments to my java code manually (either command line or Eclipse) and debug this code step by step.
If you will recommend me to do it in Eclipse please please write each step explicitly. I am having trouble in using Eclipse. Once it works, everything will be a lot easier.
Thanks,
So this is the first part of the story.
Now, I wanna pass these input arguments to my java code manually (either command line or Eclipse) and debug this code step by step.
If you will recommend me to do it in Eclipse please please write each step explicitly. I am having trouble in using Eclipse. Once it works, everything will be a lot easier.
Thanks,
How big is the program ?
Do you want to learn using Eclipse and all this stuff or your goal is just to make this program work?
It's always better to have a good logging strategy than to resort to debugging - particularly that kind of debugging
ASKER
@for_yan: First I want this program to work. But secondly, I want to learn and not struggle with this kind of obstacle again.
The code is not big. It is just one file around 500 lines of code. This code talks to a web application to update data.
Thanks,
The code is not big. It is just one file around 500 lines of code. This code talks to a web application to update data.
Thanks,
OK, do you know how to create a new empty propject in Eclipse?
ASKER
I think I know but there aren't only one.
or
File -> New - > Java Project
or
File -> New - > Project
Yes,
File -> New - > Java Project
and then type the name
and then it will show next screen
and you can say OK there
File -> New - > Java Project
and then type the name
and then it will show next screen
and you can say OK there
ASKER
I said finish and now i have the project. I also added external jar which I will need them to run the code.
Now under the project I have these.
Now what am I gonna do?
Thanks
Now under the project I have these.
src
JRE System Library
Referenced Libraries
Now what am I gonna do?
Thanks
OK.
No take your jar file - make absolutely separate folder on your drive - put there .jar
copy it to another file and rename that another file to .zip
and then expand this .zip in here - in this folder where you are.
How many .java files do you have ?
Are they all in one folder?
No take your jar file - make absolutely separate folder on your drive - put there .jar
copy it to another file and rename that another file to .zip
and then expand this .zip in here - in this folder where you are.
How many .java files do you have ?
Are they all in one folder?
ASKER
I copied the jar in a separate folder.
Renamed it as .zip
Expanded it
Now in that folder I have
com and META-INF folders
couple of jar files (the libraries)
there are subfolders under com. Like mycompany>tools>projectNam e
and there is one .class file. But no .java files. Because I already compiled it in Maven.
What is next?
Renamed it as .zip
Expanded it
Now in that folder I have
com and META-INF folders
couple of jar files (the libraries)
there are subfolders under com. Like mycompany>tools>projectNam
and there is one .class file. But no .java files. Because I already compiled it in Maven.
What is next?
Do you have original Java file(s)? Those which you compiled.
How many there are?
Are they all iin one folder?
How many there are?
Are they all iin one folder?
ASKER
I have only one Java file. Here is the problem. They are in a Maven project structure. If I take them out then it won't work.
So what I heard is I need Maven plugin for Eclipse which gives the ability to import maven project into Eclipse.
Can we go with this direction?
Thanks,
So what I heard is I need Maven plugin for Eclipse which gives the ability to import maven project into Eclipse.
Can we go with this direction?
Thanks,
you cant traces the values in the jar file.
> If I take them out then it won't work.
Java is java.
Well, I suggest you first at least learn how to use Eclipse in normal way.
ASKER
I installed maven plugin for eclipse.
Now how can I get this maven project into Maven?
File -> New ->Other -> Maven -> Maven Project
Then what am I gonna do?
Now how can I get this maven project into Maven?
File -> New ->Other -> Maven -> Maven Project
Then what am I gonna do?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
ok i got it. THanks,
Check here:
http://www.javaworld.com/javaworld/javaqa/2000-06/04-qa-0623-jdb.html
http://download.oracle.com/javase/1.3/docs/tooldocs/solaris/jdb.html
You probably do not want to do it - it would be too painful