Software Development

Why is javac not recognized as an internal or external command on Windows 11?

LI Asked by Lisa Ray · 12-05-2023
0 upvotes 15,699 views 0 comments
The question

I just installed the JDK 21 to start my software development journey, but when I type 'javac -version' in the command prompt, I get the error that it is not recognized. I can see the files in my Program Files folder. How do I make the terminal realize that Java is actually installed? 

3 answers

0
DE
Answered on 14-05-2023

The issue is that the directory containing javac.exe isn't in your system's PATH variable. You need to go to System Properties > Environment Variables. Under System Variables, find 'Path' and click Edit. Add a new entry that points to your JDK bin folder, usually something like C:\Program Files\Java\jdk-21\bin. After saving, you MUST restart your Command Prompt or PowerShell window for the changes to take effect. This is a crucial step in setting up any local development environment for Java-based software development. 

0
KE
Answered on 15-05-2023

Have you tried running the command java -version (without the 'c') to see if the Runtime Environment is detected even if the compiler isn't? Sometimes the JRE is mapped but the JDK isn't. 

ST 16-05-2023

I tried java -version and it works! It shows version 21. Why would the runtime work but the compiler javac fail? Is it because they are located in different folders within the Java directory structure, or did the installer just fail to map the development tools properly during the setup?

0
BR
Answered on 17-05-2023

You need to set your JAVA_HOME variable first, then add %JAVA_HOME%\bin to your Path. This makes it much easier to update versions later on. 

LI 18-05-2023

Exactly, setting JAVA_HOME is the professional way to do it. Most enterprise IDEs like IntelliJ or Eclipse look for that specific variable to function correctly anyway.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

Book Free Session