Link to home
Create AccountLog in
Avatar of Tolgar
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,
Avatar of for_yan
for_yan
Flag of United States of America image

Waht is your goal? Please, elaborate.
If you have source codes there are definitely easier ways to do it
Avatar of Tolgar
Tolgar

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,


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?
Avatar of CEHJ
It's always better to have a good logging strategy than to resort to debugging - particularly that kind of debugging
Avatar of Tolgar

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,
OK, do you know how to create a new empty propject in Eclipse?
Avatar of Tolgar

ASKER

I think I know but there aren't only one.

File -> New - > Java Project 

Open in new window


or

File -> New - > Project 

Open in new window

Yes,
File -> New - > Java Project
and then type the name
and then it will show next screen
and you can say OK there
Avatar of Tolgar

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.

src
JRE System Library
Referenced Libraries

Open in new window


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?
Avatar of Tolgar

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>projectName

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?
Avatar of Tolgar

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,
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.

Avatar of Tolgar

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?

ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Tolgar

ASKER

ok i got it. THanks,