PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Java · Theory

How to set path in Java

← All stacks

Theory

7/270

How to set path in Java

PATH is how your computer finds java and javac. If PATH is wrong, the terminal says the command is not recognised. This is a setup topic, not a coding topic — but labs and viva ask it.

Install a JDK (not only JRE if you want to compile). Inside the JDK folder, bin has java and javac. Add that bin folder to PATH. Many tools also want JAVA_HOME pointing at the JDK root folder.

Open a new terminal after you change PATH — the old window still uses the old PATH. Then run java -version and javac -version. If javac is missing, you installed JRE only, or PATH is wrong.

Let's take this on the board with one tiny Main class — no extra files. How to set path in Java — reads JVM properties — proves your runtime is available. Start from main, go line by line, and stop at each print. That output is the proof for How to set path.

Diagram
JDK folder
      │
      ▼
     bin / java + javac
      │  add to PATH
      ▼
  java -version
Exam tip

PATH finds the tools. JAVA_HOME is the JDK folder. Then show java -version and javac -version.

Example

// JVM / runtime info
public class Main {
  public static void main(String[] args) {
    System.out.println("java.version = " + System.getProperty("java.version"));
    System.out.println("java.home = " + System.getProperty("java.home"));
    System.out.println("os.name = " + System.getProperty("os.name"));
  }
}

How to set path in Java — reads JVM properties — proves your runtime is available.

Short notes

  • DefPATH tells the computer where java and javac live.
  • RuleAdd JDK bin to PATH. JAVA_HOME = JDK root folder.
  • RememberOpen a new terminal after changing PATH.
  • TrapJRE only → javac not found. Student needs JDK.

Questions

1

What is PATH for?

2

What is JAVA_HOME?

3

Why is javac missing?

Previous← Program InternalNextDifference between JDK, JRE and JVM →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.