CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > Java > How to solve ‘javac or java not recognized’ error

Java Tutorial

  • Introduction
    • What is Java
    • History Of Java
    • Install Java
    • What is JVM
    • JDK vs JRE vs JVM
    • Java Bytecode
    • OOP vs POP
    • Compile and Run Java
  • Tokens, Expressions and Control Structures
    • Primitive data types
    • Integers
    • Floating Points
    • Characters
    • Booleans
    • User Defined Data Type
    • Declarations
    • Constants
    • Identifiers
    • Literals
    • Type Conversion and Casting
    • Variables
    • Default Variable Initialization
    • Command Line Arguments
    • Arrays of Primitive Types
    • Comment Syntax
    • Garbage Collection
    • Expressions
    • Operators
    • Arithmetic Operator
    • Bitwise and Shift Operator
    • Comparison or Relational Operators
    • Logical Operators
    • Assignment Operators
    • Ternary Operator
    • Increment and Decrement Operator
    • Control Statements
  • OOP Concepts
    • Class and Object
    • Create Class Instance
    • Method
    • Abstraction
    • Encapsulation
    • this keyword
    • Constructor
    • Pass by Value
    • Access Modifier/Control
    • Polymorphism
    • Method Overloading vs Method Overriding
    • Recursion
    • Nested and Inner Class
  • Inheritance and Packaging
    • Inheritance
    • extends Keyword
    • super Keyword
    • Object Class
    • Abstract class
    • Final Class
    • Java Package
    • Interface
  • Handling Error/ Exceptions
    • What is Exception
    • Exception Handling Keywords
    • Common Java Errors
    • User Defined Exception
    • Throwing and re-throwing Exception
    • finally Block
  • Strings
    • Java String Tutorial
  • Threads
    • Introduction
    • Create Thread
    • Thread Lifecycle
    • Thread Priority
    • Thread Synchronization
    • Inner Thread Communication
    • Thread Deadlock
  • IO and Streams
    • java.io Package
    • Files and Directories
    • Byte Stream
    • Character Stream
    • Console Input and Output
    • Serializable and Deserializable
  • Core Packages
    • java.lang Package
    • Math
    • Wrapper Classes
    • java.lang.Number
    • Double
    • Float
    • Integers
    • java.lang.Byte
    • java.lang.Short
    • java.lang.Long
    • java.lang.Character
    • java.lang.Boolean
    • java.util package
    • Vector Class
    • Stack Class
    • Dictionary Class
    • Hashtable
    • Enumeration or Enum
    • Generate Random Number
  • Holding Collection of Data
    • Arrays
    • Map
    • List
    • Set
    • Collection Interface
    • Collections Class
    • ArrayList
    • HashSet
    • TreeSet
    • Comparator
  • Java Bean
    • What is Java Bean
    • Advantages and Disadvantages of Java Bean
    • Java Beans API
    • Introspection
    • Java Bean Properties
    • Bound and Constrained Properties
    • BeanInfo Interface
    • Customizers
    • Java Beans Persistence
    • BeanDescriptor

How to solve ‘javac or java not recognized’ error

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: July 1, 2026 · 2 min read · 0 Comments
Share: in X

There are a few things you can try if you are experiencing the error “javac or java is not recognized” when trying to use the javac or java commands in your command prompt or terminal.

  1. Make sure that you have the Java Development Kit (JDK) installed on your system. The javac command is included in the JDK, so you need to have it installed to be able to use it to avoid error “javac or java is not recognized”.
  2. Check that the location of the JDK installation is included in your system’s PATH environment variable. The PATH is a list of directories that your system searches for executables when you type a command in the terminal. To check if the JDK installation directory is included in the PATH, you can follow these steps:
  • In the terminal, enter the following command:
echo %PATH%
  • This will print out the directories that are included in the PATH, separated by semicolons. Look for the directory that contains the javac executable file. On Windows, this is usually something like C:\Program Files\Java\jdk_version\bin. On macOS and Linux, it might be something like /usr/local/jdk_version/bin.
  • If you can’t find the JDK installation directory in the PATH, you will need to add it. To do this, you can follow these steps:
  • On Windows:
    • Right-click on the “My Computer” or “This PC” icon on your desktop and select “Properties”.
    • Click on the “Advanced system settings” link on the left side of the window.
    • Click on the “Environment Variables” button.
    • Under the “System Variables” section, find the “Path” variable and click on “Edit”.
    • Add the JDK installation directory to the end of the list (separated by a semicolon).
    • Click “OK” to save the changes.
  • On macOS and Linux:
    • Open the terminal and enter the following command:
export PATH=$PATH:/path/to/jdk/bin

Replace /path/to/jdk/bin with the actual path to the JDK installation directory on your system.

  • To make this change permanent, you will need to edit your shell profile file. For example, if you are using the Bash shell, you can enter the following command:
echo 'export PATH=$PATH:/path/to/jdk/bin' >> ~/.bashrc
  1. If you have installed the JDK and added it to the PATH, but you are still getting the “javac or java is not recognized” error, try closing and reopening your terminal or command prompt. This will refresh the environment variables and allow the changes you made to take effect.

By following the steps given above, the error javac or java not recognized should be solved. Thanks

Related Posts:

  • Install and Set Up Java Development Environment
  • Compile and Run Java Program
  • How to Solve “systemctl command not found” Error: A…
  • Top 10 Common Java Errors
  • MySQL Commands for Developers
  • java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Was this article helpful?
← Previous ArticleInstall MongoDB BI Connector on Ubuntu
Next Article →Character Stream in Java

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
© 2026 CoderSathi. All rights reserved. Privacy Policy · Sitemap