- Установка Java (JDK) в Windows и Linux, переменная PATH и JAVA_HOME
- Установка Java (JDK) в Windows
- Установка Java (JDK) на Linux
- How to Set Java Path in Windows and Linux?
- Setting Java Path in Windows
- How to Set Path for Java Unix Linux and Windows
- What is Path in Java
- Setting Path for Java in Unix/Linux and Windows
- 1. How to check if «java» or «javac» is in PATH
- How to set PATH for Java in windows
- 1) Setting Java PATH using command prompt in windows
- 2) Setting Java PATH using windows environment variable editor
- How to set Java PATH in UNIX or Linux
- 9 comments :
Установка 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, причем очень популярная.
Откройте терминал и напишите команду для установки пакета:
Осталось подтвердить установку и на этом всё, Java установлена! Единственное, что меняется — это прописывание путей до компилятора.
Чтобы прописать JAVA_HOME в окружение, выполните следующую команду (только убедитесь, что такой каталог уже есть):
Чтобы прописать компилятор Java в PATH, выполните другую команду (опять же, ваши пути до Java могут отличаться от моих):
На этом установка закончена. Чтобы проверить, что всё работает правильно, достаточно написать в терминале:
О том, как же всё-таки писать на Java, мы расскажем в следующий раз.
Источник
How to Set Java Path in Windows and Linux?
PATH is an environment variable that is used by Operating System to locate the exe files (.exe) or java binaries ( java or javac command). The path once it is set, cannot be overridden. The PATH variable prevents us from having to write out the entire path to a program on the Command Line Interface every time we run it. Moreover, the path is just a variable that stores a bunch of shortcuts.
To execute java console-based programs in windows or Linux environments we have to use java and javac commands. The commands java, javac are not known to the operating system as we don’t specify where the executables reside. Hence, we need to specify the path where the executables are located. This is the reason we set the path and specify the path of the bin folder because the bin contains all binary executable files. After setting the path it can load all necessary items in the program including the compiler or interpreter itself.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
Below is the procedure for setting the path for both Windows and Linux:
Setting Java Path in Windows
1. Go to the Search box and type advanced system settings in it. Now click on the View advanced system settings.
2. Select the Advanced tab and then click environment variables.
3. In the system, variables click the New button. Now in the edit system variable, type variable name as JAVA_PATH and variable path as the path where the JDK folder is saved and click on OK button Usually the path of the JDK file will be C:\Program Files\Java\jdk1.8.0_60.
4. Now in the system variables go to the path and click the edit button.
5. Click the New button.
6. Now add the following path: %JAVA_HOME%\bin
Источник
How to Set Path for Java Unix Linux and Windows
PATH is one of the fundamental Environment variables on shell or DOS but it’s commonly associated with Java mainly because if we try to run a java program that doesn’t include Java executable in PATH then we say PATH is not set for Java and we need to set the path for Java. I have also seen the developer getting confused over path and classpath in java. Though both path and classpath provide run-time settings for any java environment which is required to compile and executes Java programs they are completely different from each other.
Classpath is usually used to find out classes and is mostly associated with the lib part while PATH is used to find the executable or command to be executed. In order to compile and run a java program from the command line, your PATH environment variable must have «javac» and «java» on it.
In this Java PATH tutorial, we will see what is PATH for Java, How to Set a Path for Java, and how to troubleshoot PATH related issues.
What is Path in Java
Setting Path for Java in Unix/Linux and Windows
1. How to check if «java» or «javac» is in PATH
How to set PATH for Java in windows
1) Setting Java PATH using command prompt in windows
2) Setting Java PATH using windows environment variable editor
How to set Java PATH in UNIX or Linux
9 comments :
How is it different to set PATH in Windows XP and Windows 7 ? What will happen if we don’t set PATH is there any default PATH in Java ? How can we override PATH in Java ? Also many times we need to set PATH from Command Prompt can you also let us know how to set PATH from Command Prompt in DOS, Windows and Linux ?
October 16, 2011 at 6:57 PM Reema said.
I am getting java.lang.unsatisfiedlinkerror no ocijdbc10 in java.library.path , does it anything to with path setting in Java. I have already set PATH for java in environment variable PATH , still I am getting this error, please help.
December 8, 2011 at 11:51 PM Jessy said.
I don’t think any difference in PATH setting for windows XP and windows 7 , you can set PATH either from command prompt or windows GUI. PATH is a operating system variable where it look for commands and executable. when you run java program you execute «java» command whose binary lies in JAVA_HOME/bin directory , if that directory is not included in PATH than Operating System will not find it and throw «not recognized as internal or external command»
December 8, 2011 at 11:54 PM Anonymous said.
i searched many articles especially about the path , than god , i found this excellent article
with very helpfull explanation.
June 12, 2014 at 6:06 AM Anonymous said.
In fact java.exe and javaw.exe are copied into your %systemroot% under windows on jre installation,
you won’t see any additional path entries while java will be available from command line this way
It didn’t help me with my problem
😔
It didn’t help me with my problem
Hello @Unknown, can you elaborate about your problem and what did you try, we may be able to help?
Step1 -> Go to ‘system’
step2 -> Go to advanced settings
step3 -> click on envirment Variables
step4 -> click on edit
step5 -> click on new and browse the jdk path «C:\Program Files\Java\jdk1.6.0_26\bin»
Источник