jol-cli and external class path
Aleksey Shipilev
aleksey.shipilev at oracle.com
Wed May 13 09:13:22 UTC 2015
Hi,
On 05/13/2015 02:42 AM, Bernd Eckenfels wrote:
> I noticed that on the JOL homepage the jol-cli samples all use the -jar
> executable form. With this it is not possible to specify additional
> classes on the class path.
>
> Is there a way to do it, or is it allowed/expected to use java -cp in
> this case? Should this be documented?
Yes, at the moment, that's the way you do it, classpath the JOL JAR, and
explicitly enter the Main JOL method.
There might be a better way, but I can't clearly see it now. We can
probably accept our own classpath line and set up our own URLClassLoader
to pull the selected classes from there, like:
$ java -jar jol-cli.jar internals -cp myjar.jar:myjar2.jar test.MyClass
$ java -jar jol-cli.jar internals -cp target/classes test.MyClass
> I noticed there is some pre-main instrumentation in the JAR, so do I
> need to specify an -javaagent as well?
Actually, javaagent should self-attach even without -javaagent on the
command line.
> The tests I tried worked without:
>
> java -cp target\classes;jol-cli-full.jar org.openjdk.jol.Main
> internals test.MyClass
Yeah, that should do it.
-Aleksey
More information about the jol-dev
mailing list