Lab 1d: Setting up GJDB

Setup

This semester, you should learn to use a debugger at some point. It is up to you whether you try out a debugger that is part of an IDE like Eclipse, or if you try out our command line debugger gjdb.

If you've got Eclipse installed, you don't need to do any setup. This guide is only for those of you using gjdb.

To get gjdb, you simply need to pull from skeleton and make sure that you've received gjdb.jar.

At that point, you should be able to start gjdb with java ucb.gjdb.GJDB, e.g.

$ java ucb.gjdb.GJDB Hello
gjdb version 6.4.1 (for JDK 1.7.0_25)
  Please send all questions, comments, and bug reports
  to Hilfinger@cs.berkeley.edu.
Initializing...
[-]

Q: What should I do if I get "Could not find or load main class ucb.gjdb.GJDB"? A. Your CLASSPATH doesn't include your skeleton lib folder. You'll need to make sure that you move gjdb.jar into the same folder that contains your libraries from lab 1c.

Q: What should I do I'm getting Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jdi/IncompatbleThreadStateException? A. Your CLASSPATH doesn't include tools.jar. You'll need to first find tools.jar on your computer. Most likely, it will be a subfolder of a folder called jdk1.7.0_60.jdk. For example, on my computer, it is in /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/lib/, and on my Windows computer, it is in C:\Program Files\Java\jdk1.7.0_60.jdk\lib.

Once you've found the folder that contains tools.jar, you should add this folder to your classpath using the directions from lab 1C, make sure to include a trailing *, e.g. on my machine I added: /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/lib/* to my CLASSPATH.

Important: If you add a line like export CLASSPATH="/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/lib/*" into your .bashrc or .bashprofile fodler, this replaces your old classpath so everything will break. Instead of replacing your classpath entirely, your new line in .bashrc should look something like: export CLASSPATH="$CLASSPATH:/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/lib/*". Note the $CLASSPATH at the beginning. This is the bash equivalent of something like CLASSPATH = CLASSPATH + '/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/lib/*', but it's Bash so the syntax is awful (IMO).