3

I am new in java programming. I am currently using Windows. Recently I saw a video tutorial from YouTube that the instructor was setting java JDK path in system variables then created a new variable called JAVA_HOME.

Now I saw in javaTpoint tutorial that they were setting the path in user variables didn't create any JAVA_HOME variable.

So my question is what is the difference between the set path in user variables and system variables? Which one do I have to set? and what's all about JAVA_HOME?

I didn't found any proper explanation on this. Your answer would be highly appreciated.

Learner
  • 1,170
  • 11
  • 21
  • Does this answer your question? [what is the reason for the existence of the JAVA\_HOME environment variable?](https://stackoverflow.com/questions/5102022/what-is-the-reason-for-the-existence-of-the-java-home-environment-variable) – MarsAtomic Aug 11 '20 at 03:56
  • JAVA_HOME isn't strictly necessary because the JDK doesn't use it. Other Java applications however do use it, so some tutorials have you set it as a precaution. – MarsAtomic Aug 11 '20 at 03:57

2 Answers2

5

If you set it as a user variable, it's only available to the current user. If you set it as a system variable, it's available for all users. i.e. if you log out of Windows and log in with a different user, you won't have the JDK on your system path if you set it as a user variable. If it's your personal computer and you only have one account, it doesn't matter too much. I'd recommend setting it as a system variable.

JAVA_HOME is used by Gradle and Maven build tools (and some other things) to know where the root directory of your JDK is located. It should point to the folder where the bin folder is located, ie C:\Program Files\Java\jdk-11.0.7. If you're just starting out, I wouldn't worry about it too much. It's not necessary until you start using more complex tools for development.

scgrk
  • 159
  • 2
  • 4
  • Adding extra points. If you want to give all the users to a one version of java as a base user system variable section and the current user or any user need a specific then you can use user variable section to point out specific version of java to that user only. – sujith s Feb 02 '23 at 10:57
1

The difference is user variables means the variable will only be able to be used & called by the user it was created by. On the other hand, for system variables, all users can use that variable.

I would recommend setting it to the system variables for compatibility, accessibility and less chance of creating errors of variable not found.

Jessy Guirado
  • 220
  • 1
  • 7