Set java path windows command

Установка Java (JDK) в Windows и Linux, переменная PATH и JAVA_HOME

Java — язык общего назначения, основанных на классах, поддерживающий многопоточность и являющийся объектно-ориентированным. Программы на Java компилируются в так называемый byte-код, который в свою очередь запускается Виртуальной Машиной Java (Java Virtual Machine — JVM), независимо от архитектуры компьютера. На данный момент последняя версия Java двенадцатая.

Ниже мы рассмотрим — как установить Java на Windows и Linux. Для каждой из платформ создана своя версия JDK, JRE и JVM, хотя сами программы на Java и не меняются от платформы к платформе (что логично).

Давайте проясним несколько вещей перед тем, как мы начнем.

  • JDK (Java Development Kit) — эта штука нужна для разработчиков на Java (то есть нас) и включает в себя инструменты разработки, документирования, упаковки и так далее (в том числе компилятор Javac, Javadoc, Jar-упаковщик и дебаггер).
  • JRE (Java Runtime Environment) — сюда включены библиотеки Java, которые необходимы для запуска Java-программ. Эта штука нужна обычным пользователям и не содержит инструментов для разработки.
  • JVM (Java Virtual Machine) — это и есть сама виртуальная машина Java, которая непосредственно и запускает наши Java-программы (байткод). Ее реализация написана для множества железа и платформ.

Установка Java (JDK) в Windows

Первым делом необходимо скачать JDK с официальной страницы Oracle. В нашем случае нужна версия под Windows, в самом низу.

После установки запустите скачанный exe-файл и установите его на ваш компьютер. Как только вы это сделаете, нужно будет настроить окружение.

Перейдите в Панель управления -> Система и безопасность -> Система. На вкладке «Дополнительно» нажмите на «Переменные среды», как показано ниже:

Теперь нужно найти и дополнить переменную PATH так, чтобы она содержала путь до установленной Java. Выберите PATH и нажмите «Изменить»:

Вы увидите список уже установленных переменных. Сейчас необходимо нажать «Новый» и добавить путь, по которому установлена Java (каталог bin!). По умолчанию это обычно «C:\Program Files(x86)\Java\jdk\bin».

Нажмите «Готово» (или «Ок»), сохраните настройки и на этом всё готово! Чтобы проверить, что установка прошла корректно, откройте консоль и введите:

Если вы получили сведения о версии Java, значит всё хорошо.

Установка Java (JDK) на Linux

В Linux есть несколько способов установить Java. Мы опишем самый простой и быстрый, с использование терминала. И в данном случае мы установим OpenJDK. OpenJDK — это бесплатная и свободная реализация виртуальной машины Java, причем очень популярная.

Читайте также:  Аватар для mac os

Откройте терминал и напишите команду для установки пакета:

Осталось подтвердить установку и на этом всё, Java установлена! Единственное, что меняется — это прописывание путей до компилятора.

Чтобы прописать JAVA_HOME в окружение, выполните следующую команду (только убедитесь, что такой каталог уже есть):

Чтобы прописать компилятор Java в PATH, выполните другую команду (опять же, ваши пути до Java могут отличаться от моих):

На этом установка закончена. Чтобы проверить, что всё работает правильно, достаточно написать в терминале:

О том, как же всё-таки писать на Java, мы расскажем в следующий раз.

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 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.

Читайте также:  Что такое центр обновления windows отключен администратором

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.

How can I set the PATH variable for javac so I can manually compile my .java works?

Here’s the address on my drive:

How would I go about setting the path variable so I can go in command window (windowskey+r «cmd») and be able to type things like:

I’m using Windows 7 Professional.

9 Answers 9

Typing the SET PATH command into the command shell every time you fire it up could get old for you pretty fast. Three alternatives:

  1. Run javac from a batch ( .CMD ) file. Then you can just put the SET PATH into that file before your javac execution. Or you could do without the SET PATH if you simply code the explicit path to javac.exe
  2. Set your enhanced, improved PATH in the «environment variables» configuration of your system.
  3. In the long run you’ll want to automate your Java compiling with Ant. But that will require yet another extension to PATH first, which brings us back to (1) and (2).
Читайте также:  Ctrl alt delete при запуске компьютера windows

You can also append ;C:\Program Files\Java\jdk1.6.0_18\bin to the PATH in the user environment dialog. That would allow you to use javac and other java tools directly form any cmd shell without setting the path first. The user environment dialog used to be somewhere in the system properties in XP, I have no idea where it is in Windows 7.

Step 1: Set the PATH variable JAVA_HOME to the path of the JDK present on the system. Step 2: in the Path variable add the path of the C:\Program Files\Java\jdk(version)\bin

This should solve the problem. Happy coding!!

  1. Type cmd in program start
  2. Copy and Paste following on dos prompt

Follow the steps given here

after setting variable, just navigate to your java file directory in your cmd and type javac «xyx.java»

or if you don’t navigate to the directory, then simply specify the full path of java file

First thing I wann ans to this imp question: «Why we require PATH To be set?«

Answer : You need to set PATH to compile Java source code, create JAVA CLASS FILES and allow Operating System to load classes at runtime.

Now you will understand why after setting «javac» you can manually compile by just saying «Class_name.java»

Modify the PATH of Windows Environmental Variable by appending the location till bin directory where all exe file(for eg. java,javac) are present.

Example : ;C:\Program Files\Java\jre7\bin.

How to Set Java Path On Windows?

When we set the environment path, can’t it work correctly for Java, Eclipse and Android Studio?
How to set it correctly?

When I set it temporarily by using the command prompt, set path is not working correctly.
So I tried to set it permanently by using the environment variable Path, but it’s not possible.

How can I set it properly?
Please give me a detailed explanation

2 Answers 2

Apart from setting the JAVA_HOME system variable you need to set the Path variable as well because the Path is the system variable that your Operating system uses to locate the needed executable from the terminal window.

So for setting the Path Variable proceed as follows:

  • Right click on the My Computer icon —> Properties —>Advanced system settings —> Environment Variables
  • Now under System variable scroll to the Path variable
  • Select Path variable and click on edit button
  • Now add %JAVA_HOME%\bin in the end of Variable values, separating this value form the existing one in the list with a ; eg xxxxx;%JAVA_HOME%\bin;

Note that before following the above steps also check if your JAVA_HOME variable is properly set. For doing this go to command prompt and type echo %JAVA_HOME%. If it is properly set then it will give you the path of your jdk.

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