The ‘:javap’ command in the scala 2.9.1 console need the tools.jar (from JDK6) in the ‘classpath’. From cmd-line it could be done with ‘-cp’ argument or CLASSPATH environment variable.
How to do the same for scala console that invoked from SBT with the ‘console’ and ‘console-quick’ commands?
Long answer, that might help you elsewhere.
If I want to know about something in SBT, I
inspectit:Ok, there’s an interesting dependency in
compile:full-classpath. I wish it werecompile:full-classpath(for console), but it isn’t. It shouldn’t cause me trouble in this case, though. Let’sinspectit.Ok, I could go further into the dependencies, but I don’t think it’s necessary. Let’s see what’s inside it:
Ok, nothing unexpected there. Let’s add
tools.jar.To change something I have to use
set, and I have to respect a bunch of camel case and other rules to get it working. If I hadcompile:full-classpath(for console), that would becomefullClasspath in Compile in console. Note the uppercase inCompile, and thatfull-classpathbecamefullClasspath, and the general reordering of element names. Details here.I think one should be able to take the output of
show(or, at least,inspect) and feed it right back toset, but that’s not the case (for now, anyway), so just learn these conversions rules.I don’t want to retype everything, just add one JAR file. I need to use
+=for that. The operators used to change thing can be found here.The classpath seems to need some
Attributedstuff. Check the detailed docs on Classpath in the SBT wiki, and figure how to come up with one. Fortunately, most values I may want to change aren’t as difficult to create as this one.Seems to have worked. Let’s
showits content to confirm, since even writingcompileinstead ofCompilemight get it to change the wrong thing.Yep, there it is. Let’s test it:
Success!!!
Of course, this session is a lie. It took much longer for me to arrive there, but that’s mostly practice.