-1

I can't use javah -v XX to look the constant pool structure

the code:

public class Demo {
    private int m;

    public int plus() {
        return m + 1;
    }
}

execute javac Demo.java and generated the Demo.class

so, I type the command javah -v Demo, but an error has occurred:

Error: Could not find class file for 'Demo'.

I have tried javah -v Demo.class, but there is also an error message:

Exception in thread "main" java.lang.IllegalArgumentException: Not a valid class name: Demo.class
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:177)
at com.sun.tools.javac.api.JavacTool.getTask(JavacTool.java:68)
at com.sun.tools.javah.JavahTask.run(JavahTask.java:509)
at com.sun.tools.javah.JavahTask.run(JavahTask.java:335)
at com.sun.tools.javah.Main.main(Main.java:46)

but I want somthing like:

image

this is My javah path :

   /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/bin/javah

thank you very much!

Lex
  • 13
  • 1
  • 5

2 Answers2

1

Try to correct the path to your class with the real path and the package structure if required. For ex. if the Demo.class is in a package called demo, do this:

javah -v demo.Demo
mdp
  • 171
  • 1
  • 1
  • 8
1

To view class constant pool you need javap tool, not javah.

If Demo.class is in current directory, specify . as the class path:

javap -cp . -v Demo
apangin
  • 92,924
  • 10
  • 193
  • 247