- How To Set Java, JRE and JDK Home Path and Environment Variables On Windows?
- Locate JRE or JDK Path
- Set Java HOME_PATH Environment Variable
- Set JAVA Executable Path
- Check Java Is Working
- 3 thoughts on “How To Set Java, JRE and JDK Home Path and Environment Variables On Windows?”
- How to set the java path and classpath in windows-64bit
- 5 Answers 5
- Java File Path Windows/Linux [closed]
- 5 Answers 5
- Window add Java to Path
- 2 Answers 2
- Not the answer you’re looking for? Browse other questions tagged java windows path or ask your own question.
- Linked
- Related
- Hot Network Questions
- Subscribe to RSS
- How to specify jdk path in eclipse.ini on windows 8 when path contains space
- 15 Answers 15
- Details
- Notes
- Gotcha JAVA_HOME
- Finding a VM
- Verfication
How To Set Java, JRE and JDK Home Path and Environment Variables On Windows?
Java is a very popular programming language which provides a different component in order to run, develop Java applications. JRE or Java Runtime Environment is used to run Java application. JDK or Java Development Kit is used to develop Java applications. In this tutorial, we will learn how to set up Java, JRE, and JDK operating system path variables in order to work properly.
Locate JRE or JDK Path
Before starting the configuration we have to locate the JRE or JDK path. JRE or JDK generally installed on the Program Files or Program Files(x86) directory under the Java directory like below.
Locate JRE or JDK Path
and under the Java directory the JDK is residing.
Locate JRE or JDK Path
Set Java HOME_PATH Environment Variable
Now we have learned the path of the Java, JRE or JDK installation. We can set this path as Java HOME_PATH environment variable. We will open the computer properties with by running sysdm.cpl in the Run menu like below. We can also open it from the File Explorer -> Computer -> Right Click.
Open System Properties
In the system properties, we will navigate to the Advanced tab which provides the Environment Variables button like below.
Open Environment Variables
Below we can see the environment variables menu where we will create the JAVA_HOME system variable and set the path accordingly. We click to the New in order to create a new system variable.
Create New System Variable
Here we will set the Variable Name as JAVA_HOME and the Variable Value the path or Java, JRE or JDK which is C:\Program Files\Java\jdk-12 in this example. Then we will click OK.
Set JAVA Executable Path
If we want to run java.exe or similar executables provided by JRE or JDK we have to add the path of Java in the Path variable like below. We select the system variable named Path and click to the Edit .
Here we click to New which will add a new line to the existing values.
Here we will set the bin folder path which is C:\Program Files\Java\jdk-12\bin in this example.
Add Path System Variable
Then we will click OK and OK in the environment variables screen which will save and activated new path configuration.
Check Java Is Working
We can check the new path configuration simply opening a new command line interface MS-DOS. Then just type java -version which will execute java.exe with the -version option. We can see the current java binary version by running it.
3 thoughts on “How To Set Java, JRE and JDK Home Path and Environment Variables On Windows?”
What is the point in setting the JAVA_HOME to the path to the jdk install folder path if you then edit the Path variable and add the full path to the jdk bin folder? Shouldn’t you make use of the JAVA_HOME variable and add %JAVA_HOME%\bin to the Path instead.
@James Coffey, maybe the point of setting JAVA_HOME is just in preparation for GlassFish:
https://docs.oracle.com/cd/E19182-01/820-7851/inst_cli_jdk_javahome_t/index.html
Still, the author could make use of it in Path as you say, but maybe the author is just trying to keep it simple.
THANK YOU SO MUCH. YOU SAVED MY LIFE. I need to use java in jupyter
How to set the java path and classpath in windows-64bit
I have installed java on windows-64bit OS. but when I execute javac, it is failing with the
error message no such command is available». I have created following environmental variable
CLASSPATH C:\Program Files (x86)\Java\jdk1.6.0_05\lib
5 Answers 5
Add the appropriate javac path to your PATH variable. java.exe will be found under the bin directory of your JDK. E.g.
Before answering your question, just wann ans this simple question : Why we need PATH and CLASSPATH?
Answer:
1) PATH: You need to set PATH to compile Java source code, create JAVA CLASS FILES and Operating System to load classes at runtime.
2) CLASSPATH: This is used by JVM and not by OS.
Answer to your question :
Just make sure you have Modified PATH variable (Windows System Environmental Variable) so that it points to bin dir which contains all exe for example: java,javac and etc. In my case it is like this : ;C:\Program Files\Java\jre7\bin.
So, it doesn’t matter your system is 32 bit/64 bit until and unless you specify/Modify the PATH variable correctly.
Actually, the most conventional way of getting it done on Windows is
- Go to Control Panel
- Click System
- Open Advanced settings
- Click Environment Variables.
Path is one of the variables under «System Variables». This is where the system will search when you try to execute a command.
- just append the full path to the Bin folder under your Java installation path. You can copy it using Windows Explorer to avoid typing it manually
- click OK to close the dialogs.
To verify, open the command window aka console window (for example, WindowsKey-R cmd.exe ) and run:
If the java bin folder is in the path, the system will find and execute the javac.exe file located there, and you will see your Java version. Something like:
Very Simple:
You need to set the two environment variables only; PATH and java
=>Right Click on My computer
=>Properties
=>Click on left hand side bar menu «Advanced system settings» => Click on «Environment Variables» button refer below fig.
=>Follow the below steps to Set User variable and System variable.
To Set User variable named as «PATH«
- Click on «New» button in user variables section.
- Set the variable name as «PATH» and variable value as per your java installed version.(Shown in below fig.)
To Set System variable named as «java«
Click on «New» button in System variable tab.
Set the variable name as «java» and variable value as per your java installed version.(Shown in below fig.) Refer below images for the reference.
Java File Path Windows/Linux [closed]
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed last year .
what is the best solution to create file path in Java for this two OS. Application will be used for this os , the i need to create universal String.
for example : For Linux:
Or is the best solution to generate 2 .jar files for this OS.
Thank a lot guys.
5 Answers 5
The best thing is to let java decide that for you like this
You can use slash character as file separator for both OS, in other words you can use C:/PDFMalwareDataAnalyser/Txt/ instead of C:\\PDFMalwareDataAnalyser\\Txt\\ it will still work on Windows OS.
Use System.getProperty(«os.name») for obtaining os name, depends on it set path to resource:
Try this line of code and according to the string return you can adjust your code
Personally I think you’d better get the folder passed in by a system property:
java -Dfolder=C:\PDFMalwareDataAnalyser\Txt\ myapp
This one you can use like this:
Or pass the folder by a program argument:
java myapp C:\PDFMalwareDataAnalyser\Txt\
And then use it like this:
But if you’re sticking to use constants in your code, you can use it like this:
Or a newer version of this would be:
Or you could also read a property file and store the path in that one. This would work for different OSes, you only have to create the property files before:
Window add Java to Path
I used to use My Computer -> Environment variables to set up PATH for Java, but where can I find the same in Windows 8?
2 Answers 2
Type: Control Panel
In the control panel search box, enter:
Edit environment variables for your account
Edit the system environment variables
The environment variable dialog itself is very similar to the one under previous versions of Windows.
Set Environment variable using Command Prompt in easy two steps:
Example of windows SET command:
Step 1. Print the PATH environment variable
Step 2. Add one variable to path ( For example : Java SDK )
Verify the Change
Not the answer you’re looking for? Browse other questions tagged java windows path or ask your own question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
How to specify jdk path in eclipse.ini on windows 8 when path contains space
This doesn’t work -vm %JAVA_HOME%/bin/javaw.exe
How can I replace %JAVA_HOME% with full path on Windows 8 when path contains space («Program Files» directory)
15 Answers 15
Have you tried it. Don’t put everything in single line.
Need to put the folder that contains the javaw or java executable. Under Ubuntu 18 with eclipse 4.7.1 I was able to get it to run with:
If it doesn’t work then please confirm you have added above lines before -vmargs in eclipse.ini .
Add the entry of vm above the vm args else it will not work. i.e `
The -vm option must occur after the other Eclipse-specific options (such as -product , —launcher.* , etc), but before the -vmargs option, since everything after -vmargs is passed directly to the JVM. Add the -vm option on its own line and the path to your JDK executable on the following line; e.g.
Details
Notes
- The path is on a new line below the -vm option
- There is no need to escape any characters or use slashes (back-slashes are fine)
- The path points to the bin directory, not to javaw.exe
Gotcha JAVA_HOME
When you don’t specify a virtual machine in your eclipse.ini file, you may think that the JAVA_HOME environment variable is used, but this is not the case!
From FAQ_How_do_I_run_Eclipse#Find_the_JVM
Eclipse DOES NOT consult the JAVA_HOME environment variable.
Instead the Windows search path will be scanned.
Recommendation
You may think it is a good idea to use the search path, because it is flexible.
While this is true, it also has the downside that the search path may be altered by installing or updating programs.
Thus, I recommend to use the explicit setting in the eclipse.ini file.
Finding a VM
The reason why you should specify the bin directory and not the javaw.exe (as proposed by many other answers), is that the launcher can then dynamically choose which is the best way to start the JVM. See details of the launcher process for all details:
We look in that directory for: (1) a default.ee file, (2) a java launcher or (3) the jvm shared library.
Verfication
You can verify which VM is used by your running eclipse instance in the Configuration dialogue.
In eclipse Oxygen go to Help — About Eclipse — Installation Details — Configuration