Command to find java path in windows

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_HOME – что это такое и она нужна

Во многих статьях в интернете, документации к инструментам для разработки на Java и в книгах зачастую упоминается JAVA_HOME. Что же такое JAVA_HOME?

Что такое JAVA_HOME

JAVA_HOME это переменная окружения, указывающая на директорию с установленным JDK (Java Development Kit, комплект разработчика Java). JAVA_HOME это соглашение, используемое во многих программах из экосистемы Java.

Какие программы используют JAVA_HOME

  • Intellij IDEA, Eclipse, NetBeans
  • Apache Maven, Apache Ant, Gradle
  • Apache Tomcat
  • Jenkins
Читайте также:  Linux для web дизайна

Некоторые игры, написанные на Java (например, Minecraft), тоже могут требовать установленной переменной JAVA_HOME.

Ошибки, связанные с JAVA_HOME

Если переменная окружения JAVA_HOME не определена, некоторые программы могут выдавать следующие ошибки:

  • Переменная среды java_home не определена
  • Cannot determine a valid Java Home
  • JAVA_HOME is set to an invalid directory
  • JAVA_HOME is not defined correctly
  • JAVA_HOME environment variable is not set
  • JAVA_HOME command not found
  • JAVA_HOME not found in your environment
  • JAVA_HOME does not point to the JDK

При появлении таких ошибок просто установите переменную JAVA_HOME

Как установить переменную окружения JAVA_HOME в Windows

Сперва вам нужно установить JDK или JRE.

  • Установите JDK, если вы занимаетесь разработкой программ на Java
  • Установите JRE, если вам нужно только запустить прикладную программу на Java

После установки JDK либо JRE запишите путь установки, он понадобится.

Теперь щёлкните правой кнопкой на «Мой компьютер» → «Свойства» → «Дополнительные параметры системы» → «Переменные среды…». В разделе «Системные переменные» нажмите кнопку «Создать…» и укажите следующие данные:

Имя переменной JAVA_HOME
Значение переменной Путь к директории JDK / JRE, например:
C:\Java\jdk-11.0.6

Сохраните изменения, кликнув «OK». Теперь выберите в списке переменную окружения Path и нажмите «Изменить…». В конце списка добавьте строчку со значением «%JAVA_HOME%\bin«

Для проверки откройте консоль (Win+R, cmd) и укажите последовательно укажите две команды:

Если вы правильно установили JDK/JRE и правильно установили переменные окружения, вы увидите вывод наподобие этого:

Это будет служить результатом того, что переменная JAVA_HOME установлена правильно и Java работает из командной строки.

Резюме

В данной статье мы рассказали вам, что являет собой переменная окружения JAVA_HOME, где она используется и как её корректно указать.

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

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 do I find where JDK is installed on my windows machine?

I need to know where JDK is located on my machine.

On running Java -version in cmd, it shows the version as ‘1.6.xx’. To find the location of this SDK on my machine I tried using echo %JAVA_HOME% but it is only showing ‘JAVA_HOME’ (as there is no ‘JAVA_PATH’ var set in my environment variables).

24 Answers 24

If you are using Linux/Unix/Mac OS X:

Should output the exact location.

After that, you can set JAVA_HOME environment variable yourself.

In my computer (Mac OS X — Snow Leopard):

If you are using Windows:

Windows > Start > cmd >

If you have a JDK installed, the Path is displayed,
for example: C:\Program Files\Java\jdk1.6.0_30\bin\javac.exe

In Windows at the command prompt

$PATH:i, but as you wrote, it won’t work if you didn’t set it in the PATH. – Nimrod Feb 28 ’18 at 14:59

In windows the default is: C:\Program Files\Java\jdk1.6.0_14 (where the numbers may differ, as they’re the version).

Читайте также:  Gulp установка mac os

Java installer puts several files into %WinDir%\System32 folder (java.exe, javaws.exe and some others). When you type java.exe in command line or create process without full path, Windows runs these as last resort if they are missing in %PATH% folders.

You can lookup all versions of Java installed in registry. Take a look at HKLM\SOFTWARE\JavaSoft\Java Runtime Environment and HKLM\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment for 32-bit java on 64 bit Windows.

This is how java itself finds out different versions installed. And this is why both 32-bit and 64-bit version can co-exist and works fine without interfering.

Plain and simple on Windows platforms:

where java

On Windows 10 you can find out the path by going to Control Panel > Programs > Java. In the panel that shows up, you can find the path as demonstrated in the screenshot below. In the Java Control Panel, go to the ‘Java’ tab and then click the ‘View’ button under the description ‘View and manage Java Runtime versions and settings for Java applications and applets.’

This should work on Windows 7 and possibly other recent versions of Windows.

The batch script below will print out the existing default JRE. It can be easily modified to find the JDK version installed by replacing the Java Runtime Environment with Java Development Kit.

Under Windows, you can use

to print the full path of each and every «java.exe» on your C: drive, regardless of whether they are on your PATH environment variable.

In a Windows command prompt, just type:

Or, if you don’t like the command environment, you can check it from:

Start menu > Computer > System Properties > Advanced System Properties. Then open Advanced tab > Environment Variables and in system variable try to find JAVA_HOME.

PATH and CLASSPATH

This section explains how to use the PATH and CLASSPATH environment variables on Microsoft Windows, Solaris, and Linux. Consult the installation instructions included with your installation of the Java Development Kit (JDK) software bundle for current information.

After installing the software, the JDK directory will have the structure shown below.

The bin directory contains both the compiler and the launcher.

Update the PATH Environment Variable (Microsoft Windows)

You can run Java applications just fine without setting the PATH environment variable. Or, you can optionally set it as a convenience.

Set the PATH environment variable if you want to be able to conveniently run the executables ( javac.exe , java.exe , javadoc.exe , and so on) from any directory without having to type the full path of the command. If you do not set the PATH variable, you need to specify the full path to the executable every time you run it, such as:

The PATH environment variable is a series of directories separated by semicolons ( ; ). Microsoft Windows looks for programs in the PATH directories in order, from left to right. You should have only one bin directory for the JDK in the path at a time (those following the first are ignored), so if one is already present, you can update that particular entry.

The following is an example of a PATH environment variable:

It is useful to set the PATH environment variable permanently so it will persist after rebooting. To make a permanent change to the PATH variable, use the System icon in the Control Panel. The precise procedure varies depending on the version of Windows:

Windows XP

  1. Select Start, select Control Panel. double click System, and select the Advanced tab.
  2. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New .
  3. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.
Читайте также:  Как обновить mac os 2012 года

Windows Vista:

  1. From the desktop, right click the My Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced tab (Advanced system settings link in Vista).
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New .
  5. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Windows 7:

  1. From the desktop, right click the Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Advanced system settings link.
  4. Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does not exist, click New .
  5. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Update the PATH Variable (Solaris and Linux)

You can run the JDK just fine without setting the PATH variable, or you can optionally set it as a convenience. However, you should set the path variable if you want to be able to run the executables ( javac , java , javadoc , and so on) from any directory without having to type the full path of the command. If you do not set the PATH variable, you need to specify the full path to the executable every time you run it, such as:

To find out if the path is properly set, execute:

This will print the version of the java tool, if it can find it. If the version is old or you get the error java: Command not found, then the path is not properly set.

To set the path permanently, set the path in your startup file.

For C shell ( csh ), edit the startup file (

For bash , edit the startup file (

For ksh , the startup file is named by the environment variable, ENV . To set the path:

For sh , edit the profile file (

Then load the startup file and verify that the path is set by repeating the java command:

For C shell ( csh ):

For ksh , bash , or sh :

Checking the CLASSPATH variable (All platforms)

The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look for user classes. (Classes that are part of the JRE, JDK platform, and extensions should be defined through other means, such as the bootstrap class path or the extensions directory.)

The preferred way to specify the class path is by using the -cp command line switch. This allows the CLASSPATH to be set individually for each application without affecting other applications. Setting the CLASSPATH can be tricky and should be performed with care.

The default value of the class path is «.», meaning that only the current directory is searched. Specifying either the CLASSPATH variable or the -cp command line switch overrides this value.

To check whether CLASSPATH is set on Microsoft Windows NT/2000/XP, execute the following:

On Solaris or Linux, execute the following:

If CLASSPATH is not set you will get a CLASSPATH: Undefined variable error (Solaris or Linux) or simply %CLASSPATH% (Microsoft Windows NT/2000/XP).

To modify the CLASSPATH , use the same procedure you used for the PATH variable.

Class path wildcards allow you to include an entire directory of .jar files in the class path without explicitly naming them individually. For more information, including an explanation of class path wildcards, and a detailed description on how to clean up the CLASSPATH environment variable, see the Setting the Class Path technical note.

Оцените статью