Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I get "Error: class not found" when trying to use javap

Tags:

java

javap

I'm trying to view the bytecode of my class but doesn't find the class even though the .class file is there. I can compile the Main.java file just fine from the CLI but when using javap -c Main it doesn't find the class.

public class Main {
    public static void main(String args[]) {
        int Y = 0;
        int X = (Y + 4) * 3;
    }
}
like image 435
Schwarz Avatar asked Oct 20 '25 09:10

Schwarz


1 Answers

If the class is in the default package, and if you are in the directory where the Main.class file is, the use

javap -cp . -c Main

If your class is in the package com.foo.bar, then go th the directory where the Main.class file is (bar), then execute the following commands:

bar> cd ..
foo> cd ..
com> cd ..
> javap -cp . com.foo.bar.Main
like image 134
JB Nizet Avatar answered Oct 21 '25 21:10

JB Nizet