1

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.

3 Answers 3

3

Try this:

set path="C:\Program Files\Java\jdk.1.8.0_102\bin";%path%
Sign up to request clarification or add additional context in comments.

Comments

2

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.

2 Comments

so it should be setx JAVA_HOME "C:\Program Files\Java\jdk1.8.0\bin" than also setx why is the x there? I am a little confused
setx wil change the master environment, set itself changes only the volatile current sessions environment vars.
0
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.