Problem Java environment variables on ubuntu

I got the message "There is no Java virtual machine from your PATH environment variable. You must set the virtual machine before running this program." Does anyone know how to configure it correctly? Thanks!

+3
source share
4 answers

If you install Java on Ubuntu, you do not have to add it to your PATH yourself.

First install Java from the Ubuntu repository:

sudo apt-get install sun-java6-jre

There are several other packages: sun-java6-jdk for the JDK, sun-java6-plugin for the plug-in, etc.

Use an alternative Ubuntu mechanism to select Sun Java 6 as the standard version of Java that you want to use:

sudo update-alternatives --config java

, , Java ( Java).

: https://help.ubuntu.com/community/Java

+7

, , PATH JAVA_HOME.

java ? :

$ java -version

$ dpkg -L sun-java6-jre

debian , "dpkg..." , JAVA_HOME ,

export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.10
export PATH=$PATH:$JAVA_HOME

java.

+5

,

sudo apt-get install sun-java5-bin

> #!/bin/bash
> # Init Script for j2re
> #This goes in /etc/profile.d
> 
> JAVA_HOME=/usr/java/j2reVERSion
> PATH=$JAVA_HOME/bin:$PATH
> 
> export JAVA_HOME PATH
+2

, java.

find javac

This will return a list of all locations matching "java". Find something like "/usr/lib/jvm/java-6-sun-1.6.0.11".

Open / etc / environment with a text editor and add the following. Make sure you install JAVA_HOME in the actual path to the java installation directory that you just found:

export JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.11"
export PATH="$PATH:$JAVA_HOME/bin"
+2
source

Source: https://habr.com/ru/post/1715049/


All Articles