C.Ikongo
C.Ikongo

Reputation: 1856

How to set Java path using batch file

So I am new to using and creating batch files. I was wondering what is wrong with my file. I want to make it where it sets the path so I can compile my java file in cmd. Here is my code

@echo off
:start

rem set path="c:\Program Files\java\jdk.1.8.0_102";
set path=%path%;c:\Program Files\java\jdk.1.8.0_102
cls
pause
rem goto start

I am not to sure which one is right between the 2 paths so I was just testing.

Upvotes: 1

Views: 22667

Answers (3)

Ganesh Sha
Ganesh Sha

Reputation: 1

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_202
set PATH=%PATH%;%JAVA_HOME%\bin

Set the Java home and path like this. It worked for me

Upvotes: 0

orvi
orvi

Reputation: 3340

Try this:

set path="C:\Program Files\Java\jdk.1.8.0_102\bin";%path%

Upvotes: 3

sri m
sri m

Reputation: 36

setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0"

setx PATH "%PATH%;%JAVA_HOME%\bin";

JAVA_HOME: stores location of the JDK’s installation directory. PATH: stores paths of directories where the operating system will look, to launch the requested programs quickly.

Upvotes: 2

Related Questions