0

Im deep diving into the JVM architecture and I wanted to inspect the constant pool for one of my java classes which belongs to a Spring Boot project.

I have my compiled java class and I am trying to run:

javap -v name.class

on my class.
This command is based on the following tutorial:
https://www.baeldung.com/jvm-constant-pool

However Im getting the following error:

javap : The term 'javap' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

In my environment variables I have a variable JAVA_HOME and its set to C:\Program Files\Java\jdk-19

In path, I then add %JAVA_HOME%\bin

So does anyone know how to get it to work from anywhere without the need to run the command from inside the jdk/bin folder?

Much obliged

So far I have tried to verify that java --version and javac --version produce the same result:

java 19.0.1 2022-10-18

Java(TM) SE Runtime Environment (build 19.0.1+10-21)

Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

and

javac 19.0.1

I also tried running the command directly from the jdk/bin folder, where it actually works.
I have reviewed the following posts already and as mentioned, I have set up my stuff correctly(at least according to those instructions).

Javac Command Not Working
JDK installed but no javap?

5
  • seems like you are using PowerShell. What is the output of $Env:Path? mostly regarding the Java entry and corresponding separators (before and after the entry) ((not really a Java (language) question, more like operation system...)) Commented Mar 1, 2023 at 20:57
  • @user16320675 its C:\Program Files\Common Files\Oracle\Java\javapath; %JAVA_HOME%\bin;
    – rwd762
    Commented Mar 1, 2023 at 21:23
  • The space was added accidently when I removed everything except the Java stuff. But youre right! The JAVA_HOME doesn't seem to work properly i.e. to return the correct value. However, if thats so, how is it possible that javac and java work without problems?
    – rwd762
    Commented Mar 1, 2023 at 21:39
  • Ok tbh I dont know what I did. I removed the JAVA_HOME and pasted exactly what I had before, but now its working... Its still called 'JAVA_HOME' and still points to 'C:\Program Files\Java\jdk-19'. In my path variable, Im still referencing it using '%JAVA_HOME%\bin'
    – rwd762
    Commented Mar 1, 2023 at 21:43
  • 1
    When you change the global environment variables, it does not affect already running command line interpreters. You simply have to start a new one.
    – Holger
    Commented Apr 2 at 13:35

0

Browse other questions tagged or ask your own question.