Linux mint java home

How To Set Java Home Path In Linux?

Java is a popular programming language and framework in the IT industry. There are a lot of applications developed with Java. Java requires Java Development Kit to develop applications. Compiled java applications can run on systems those are installed Java Runtime Environment a.k.a JRE. We will look in this post on how to set and check JRE or JDK or Java Home Path.

Installation

There are two main different versions of JDK and JRE. The original vendor is Oracle which distributes and sets standards of Java. Second is an open version of JDK and JRE that are supported by Oracle. In this post, we will install the open version named as openjdk-9-jre-headless .

Installation

Check Java Status

We will look if java path already sets simple running java command which is a compiler for Java applications.

Check Java Status

Update Locate Database

This is auxiliary operation to use locate OpenJDK location we update locate database

Find JDK Location

We will look at where is JDK located and also get the JDK version. This operation can be used Oracle JDK too. Just the JDK directory name will be different.

Find JDK Location

Set Java Home

As we see there is a lot of output for JDK search we can see that the path of JDK is /usr/lib/jvm/java-9-openjdk-amd64 because it is located in usr lib. Now we will set PATH for Java

Set Java Home

Make Java Home Configuration Persistent

The previous step makes JAVA HOME available for subshells but if the system is restarted the path will be lost. So we need to make this path definition persistent. There are different methods to make persistent. We will look single and simple one. We will add path definition to the system-wide environment definition configuration. This operation requires root privileges.

An alternative method without the need for root privileges is adding Java home path definition to the normal user .bashrc file like below.

Читайте также:  Windows sp3 rus games

Make Java Home Configuration Persistent

Источник

linux-notes.org

Не знаете как установить переменные JAVA_HOME и PATH для каждого пользователя в соответствии с вашей системой Linux? Тогда эта статья «Установка переменных JAVA_HOME / PATH в Linux» именно для Вас. Я напишу ее в качестве заметки, чтобы потом быстренько вспомнить и прописать Java_Home и Path на ОС для каждого пользователя ( если понадобится).

Установка переменных JAVA_HOME / PATH в Unix/Linux

/ .bash_profile является сценарий запуска, который обычно выполняется один раз. Это конкретный файл используется для команд, которые выполняются, когда нормальные входе пользователя в систему. Common использует для .bash_profile должны установить переменные окружения, такие как PATH, JAVA_HOME, чтобы создать псевдонимы для команд оболочки, и установить права доступа по умолчанию для вновь создаваемых файлов.

Установка JAVA_HOME / PATH для одного пользователя

Зайдите в свой аккаунт (учетную запись) и откройте файл .bash_profile в любом редакторе:

Установите JAVA_HOME как показано используя синтаксис export JAVA_HOME=

. Если ваш путь такой как у меня /usr/lib/jvm/java-1.6.0-openjdk-i386/bin/java, то тогда пропишите:
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-i386/bin/java

Чтобы установить PATH пропишите:

Замените путь /usr/java/jdk1.5.0_07 на свой. Сохраните и закройте файл. Просто выйдите и зайдите обратно (перелогиньетсь), чтобы увидеть изменения или чтобы все изменения вступили в силу, выполните команду:

Чтобы проверить отображение новых настроек, используйте команды:

Совет: Используйте следующую команду, чтобы узнать точный путь Java под UNIX / Linux:

Пожалуйста, обратите внимание, что файл

/.bashrc похож на

/.bash_profile но работает только для оболочки Bash и .bashrc работает для каждой новой Bash оболочки.

Установка JAVA_HOME / PATH для всех пользователей

Вам нужно добавить строки в глобальный файл конфигурации в /etc/profile ИЛИ /etc/bash.bashrc чтобы внести изменения для всех пользователей:

Добавьте переменные PATH / JAVA_PATH следующим образом:

Сохраните и закройте файл. Еще раз вам нужно ввести следующую команду, чтобы немедленно активировать настройки:

Но если не будет работать, есть еще 1 способ прописать все это дело! Сейчас я покажу как это можно сделать.

1. Устанавливаем переменные среды:

2. Выполните команду чтобы перезапустить все только что прописанные настройки:

3. Тест, если среда Java успешно установлена, введите команду в терминале чтобы проверить работу:

Установка переменных JAVA_HOME / PATH в Unix/Linux завершена.

One thought on “ Установка переменных JAVA_HOME / PATH в Unix/Linux ”

Спасибо за гайд, работает как часы. Первых пунктов до bash_profile включительно хватило. Версия х64. Пути и названия свои. Проверил еще javac -version. Вопрос к автору. Где эту информацию искать на сайте оракла?

Добавить комментарий Отменить ответ

Этот сайт использует Akismet для борьбы со спамом. Узнайте, как обрабатываются ваши данные комментариев.

Источник

Linux Mint Forums

Welcome to the Linux Mint forums!

[SOLVED] JAVA_HOME etc

[SOLVED] JAVA_HOME etc

Post by Nangabhukha » Wed Aug 28, 2019 4:45 pm

I just installed MINT 19.2 TARA.

1) The default version of java

Читайте также:  Настройка сетевого размещения windows

$ java -version
openjdk version «11.0.3» 2019-04-16
OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)

2) I have to work with Oracle jdk 8 so installed in /usr/lib/jvm/jdk1.8.0_221

3) I can work with SPRING STS fine with jdk 1.8

4) How can I fix JAVA_HOME PATH etc PERMANENTLY so I can work with ORACLE JDK1.8 in CLI and show me Oracle jdk 1.8

Re: JAVA_HOME etc

Post by rene » Wed Aug 28, 2019 5:24 pm

The .sh files currently in there are not marked executable on my system here but I could swear it used to be the case they needed to be to be executed. If you find they/it do/does: sudo chmod +x /etc/profile.d/jdk.sh . Log your user out and back in or reboot after adding the file.

[EDIT] Note, it might of course be the case that there’s currently a file like that in there for the standard JDK; don’t have things installed on the system I’m typing from. If so, clearly remove that, or at least make sure your settings override it by being later in the lexical order.

Re: JAVA_HOME etc

Post by phd21 » Wed Aug 28, 2019 6:06 pm

How to set Java environment path in Ubuntu — Stack Overflow
https://stackoverflow.com/questions/961 . tu/9613062

Hope this helps .

Re: JAVA_HOME etc

Post by Nangabhukha » Thu Aug 29, 2019 5:15 pm

Источник

Linux Mint Forums

Welcome to the Linux Mint forums!

Setting JAVA_HOME and PATH

Setting JAVA_HOME and PATH

Post by J.S.P. » Sun Aug 24, 2014 3:15 pm

I need to set JAVA_HOME and PATH variables for Java, but I’m having trouble finding out how to do this, can anyone help explain what I should do?
I’m trying to set the parent folder of the folder that holds the java bin folder as my JAVA_HOME, because that’s what I THINK I should do (the java folder containing the bin folder is located at /usr/lib/jvm/java-1.7.0-openjdk-amd64 on my system)
Here’s a load of information I think might be useful, please ask if you want to know anything else!

«echo $JAVA_HOME» gives me «/usr/lib/jvm/java-1.7.0-openjdk-amd64»
«echo $PATH» gives me «/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin:» (among other things)
«which java» gives me «/usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/java»
«java -version» gives me «java version «1.7.0_55»
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)»

A preemptive thanks for the help, I’ve tried to supply as much info as possible but please do ask if anything else would be useful.
I’m basically doing this because I’ve installed GVM so that I can install Grails through that, but every time I open a terminal GVM greets me with «GVM: JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME.» in addition to Grails not installing through GVM.

Читайте также:  Kali linux настройка часов

Re: Setting JAVA_HOME and PATH

Post by WharfRat » Mon Aug 25, 2014 3:11 pm

I’m probably the last guy to offer any insight to your dilemma as I know next to nothing about java, but I noticed two things

1) you have a different version of java than I have ( java version «1.7.0_65» )
2) which java returns /usr/bin/java

Item 2 is a symlink to /etc/alternatives/java which leads me to suspect that maybe there’s a messed up link somewhere. Check

Other oddities I noticed are I don’t have $JAVA_HOME set nor do I show any java paths with $PATH

Did you set those manually or change your /etc/environment or any bash startup files

Источник

Dushan888- Technology & FOSS for Humans

June 2012
M T W T F S S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30

History

Total Visits

Blogroll

Recent Comments

Dushan888- Technology & FOSS for Humans

My Twitts

  • Start your weekend with a cold DUSHI Purified Alkaline Water 💦 pH 9+ #dushi#time#nature#curacao#playakalki… twitter.com/i/web/status/1…3 weeks ago
  • Enjoy your DUSHI Purified Alkaline Water 💦 pH 9+ during a hot day at the beach. #dushi#time#beach#curacao… twitter.com/i/web/status/1…4 weeks ago
  • Just posted a photo @ Curaçao instagram.com/p/CQOPtBxL_tb/…3 months ago
  • Setting JAVA_HOME and ANT_HOME on Ubuntu / Linux Mint

    This might be helpful for the newbies who are starting their career in software development with Java lang. And of course its not like in old school when it comes to the industry, we use application build tools for proper deployment of enterprise applications. Such commonly used build tool is ‘ apache – ant ‘. Before starting any big work with java and ant, you have to define ‘Java home’ and ‘Ant home’ to make use of them. Follow the following steps by adding few lines to your ‘.bashrc’ file,

    Step 01: Locating .bashrc file.
    If your on ubuntu, bashrc can be found on home directory as ‘.bashrc’ . If its Linux Mint go to /etc and open ‘bash.bashrc’ as super user mode to edit via a teminal.

    sodu gedit bash.bashrc

    sodu gedit bash.bashrc

    Step 02: Setting ANT_HOME
    Include the following block of text at the bottom of your ‘bash.bashrc’ file (if ubuntu, then .bash).

    I have stored my apache-ant folder in ‘/usr/local/’. Change the path according to your apache-ant folder location.

    Step 03: Setting JAVA_HOME
    Same as you did for ANT_HOME, include the following block of text at the bottom of bash.bashrc file. Include the correct path of java jvm.

    You are good to go!

    BTW I’m listening to “Pretty Girl (The Way) ” by sugarcult. Its really cool 😛

    Источник

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