views:

507

answers:

3

Hi folks,

yes, this is a very noobish question. I'm a .NET developer and I need to step through some java code to see exactly what is going on so i can port some java into some c#. So far i've not needed to do that .. until now.

So .. i have absolutely zero knowledge of java debugging. So can someone please explain in blond-speak how i can debug the following java program, and specifically ... this line/method in the following

=> code source zipped, found here.
=> line of code: \src\com\yahoo\platform\yui\compressor\JavaScriptCompressor.java :: line 550 ... buildSymbolTree();

Now, to add to my embarassment, I have no idea what program i need to download, what steps i need to do to add this java project, add a breakpoint, start debugger, etc.

I would appreciate it if someone could provide some steps to doing this.

Oh .. this will be all installed on a virtual pc running windows xp. The only thing this virtual pc has installed on it (currently) is windows xp & the java runtime (jre-6u12....)

Thanks kindly!

Steps (will update when more info comes in)

  1. Grab/install NetBeans Ide from here. (Program to debug java with).
  2. (how to open an existing project?)
  3. (how to make a break point?)
  4. (how to start debugging .. including defining the command line args to read in the file?)
  5. (how to make a watch item?)

Wiki Mode

  • Made this a wiki so other people can edit/update the steps.
+4  A: 

Pick up netbeans or Eclipse; they're decent IDEs with decent debuggers. If you're an old fart like me, you can also use jdb, which ships with the rest of the java stuff. That's a command line tool, similar in concept to dbx and gdb.

Okay, looks like maybe it's even more detail needed.

You're going to need a Java environment. if you grab either of those IDEs you'll be able to pick one up. However, you can go to http://java.sun.com and download a JDK for your environment. You want a JDK, not a JRE (Java Runtime Environment) because you want the compilers and tools.

Another good resource is the Java Tutorial, which will lead you through the basics of setting up aqnd such (and teach you the language if you want to go into it more deeply.)

One warning: C# is almost but not quite wholly unlike Java, but it's hidden under very similar syntax. Be careful in your translation that you're getting Java that means what you think it means.

Charlie Martin
sweet. .. but i'm hoping for a list of steps please. i just don't have the time to blunder through these programs figuring out how to open existing projects, define settings, etc. I sincerly hope this isn't read as being rude or arrogant.
Pure.Krome
updated initial post.
Pure.Krome
JDK also comes with most of the JDK source - which will be very useful when stepping through the code.
Stephen Denne
No chance you might be able to edit thie initial post (cause it's now public) to save me some time, please?
Pure.Krome
Dude, the netbeans site has extensive tutorials. RTFM. or see the java Ranch Cattle Drive: http://www.javaranch.com/java-college.jsp
Charlie Martin
A: 

I have not used this in a long time... but it is a stand alone debugger: http://code.google.com/p/jswat/

I use Netbeans myself. For what you want to do, if you try Netbeans make a new Java project from existing sources and go from there.

If you have used the Visual Studio debugger then Netbeans, Eclipse, JSwat, etc... should be easy enough to figure out.

TofuBeer
+1  A: 

You should be able to transfer your debugging skils from VS, since the debuggers across netbeans & eclipse are very smiliar. Assigning breakpoints is very much the same and I'm almost certain the same hotkeys are used to step through the code. Below are some nice tutorials which may be of use to you.

Eclipse Debugging Tutorial NetBeans Debugging

CodeMonkey
One thing eclipse does well is its debugger.
Peter Lawrey
Yeah, i know i can transfer my debugging skills .. .. i'm hoping someone might be able to speed up the learning process by listing the steps, saving me the time to read up about how to use some java IDE, etc. I know it can been interpretted as 'slack' but time is of essence here, when i start.
Pure.Krome