2

I'm trying to use jol, from openJDK.

I downloaded the jar from here:
http://central.maven.org/maven2/org/openjdk/jol/jol-cli/0.4/jol-cli-0.4.jar

However, when I try to run with:
java -jar jol-cli-0.4.jar --help

I get:
no main manifest attribute, in /home/rattias/jol-cli-0.4.jar

What am I doing wrong?

CCovey
  • 799
  • 1
  • 10
  • 17
Roberto Attias
  • 1,883
  • 1
  • 11
  • 21
  • 2
    That's because you should use `jol-cli-0.4-full.jar`. – Aleksey Shipilev Apr 15 '16 at 09:06
  • @AlekseyShipilev Sorry if I might bother you, currently the link mentioned in the [openjdk jol page](https://openjdk.java.net/projects/code-tools/jol/) under *"Use as Command Line Tool"* section seems to be unreachable. On the other hand, the link to the jar available on [maven central](https://search.maven.org/artifact/org.openjdk.jol/jol-cli/0.10/jar) does not have a manifest file as mentioned in the question. Is the artifact-id incorrect? Or can you provide the correct link? (looking not to setup `hg`) – Naman Feb 06 '20 at 15:53
  • The links on OpenJDK JOL page are updated. I checked that `jol-cli-0.10-full.jar` is runnable. – Aleksey Shipilev Mar 03 '20 at 18:42

1 Answers1

1

while the precompiled jars don't seem to work, I ended up building the project from sources following the instructions here. The jol from jol-cli/target/jol-cli.jar works fine.

Roberto Attias
  • 1,883
  • 1
  • 11
  • 21
  • If I have a custom class to inspect how can I use the tool? For example if I launch java -jar jol-cli.jar internals MyPackage.MyClass I get java.lang.ClassNotFoundException – xdevel2000 Nov 28 '16 at 14:12
  • @xdevel2000 I was getting the same `java.lang.ClassNotFoundException` when I ran something like `java -jar jol-cli.jar internals MyPackage.MyClass` too. What fixed it for me was specifying the `-cp` argument. I.e., `java -jar jol-cli.jar internals -cp /path/to/my/classes MyPackage.MyClass`. NOTE: I believe that this `-cp` argument needs to be placed AFTER `internals`, which is gives the `-cp` argument as a program argument to `jol-cli.jar`'s Application Entry Point Main-Class. i.e., this is different than placing the `-cp` before `internals`, which sets the JVM classpath for the `java` command – skrueger Jun 09 '21 at 19:19