I must be doing something stupid, because this seems like such a easy operation. For some reason, I just cannot get this command to work for me. I've installed JDK, and I go into the
/bin
folder. I type:
./javap -classpath /home/Matt/workspace/VariablesTestProject/src/ -s VariablesTest.Variable
My actual filepath for the class is
/home/Matt/workspace/VariablesTestProject/src/VariablesTest/Variable.java
The error I get back is:
ERROR:Could not find VariablesTest.Variable
A command like this works however:
./javap -s java.lang.String
These are not the only commands I've tried. I've literally tried every variation I can think of, and none of them work. My javac and java commands both work fine.
Any suggestions?
javap is part of the official Java tools and allows to disassemble one or more class files. The "p" in this case stands for print, as in the official documentation is reported that: ... the javap command prints the package, protected and public fields, and methods of the classes passed to it.
A simple way to see what String literals are used in a ". class" file is to use the javap utility in your JDK installation to dump the file using the "-v" option. Then grep for text that looks like <String "..."> where ... is the String you are looking for.
Javap works against the .class
bytecode. So point the classpath at the VariablesTestProject/out
or whatever.
If you want perform operations using the javap command, first go to the jar location in cmd prompt.
Eg:
cd /usr/lib/jvm/java-6-openjdk-i386/jre/lib
(Linux)
cd D:\javasoftware\Java\jdk1.6.0_43\jre\lib
(Windows)
The above locations are the rt.jar locations. java.lang.String is the one of the classes in this jar.
Using javap you can get the information from this class.
Eg:
cd /usr/lib/jvm/java-6-openjdk-i386/jre/lib
javap java.lang.String
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With