JAVA_HOME configurado incorrectamente. ¿Cómo resetearlo?

Cuando trato de correr mvn (Apache Maven, that is), I keep getting error "JAVA_HOME" not set.

I follow the instructions to set the JAVA_HOME variable as follow; In the terminal:

user@localhost$export JAVA_HOME=/home/user/jdk1.7.0_02/bin/java

user@localhost$export PATH=$PATH:/home/usr/jdk1.7.0_02/bin

That looks correct, right? Then how come I still getting the incorrect JAVA_HOME ¿error?

preguntado el 10 de marzo de 12 a las 04:03

6 Respuestas

JAVA_HOME typically should only include the folder that contains the bin folder.

Entonces en tu caso

export JAVA_HOME=/home/user/jdk1.7.0_02/

export PATH=$PATH:$JAVA_HOME/bin

In addition for finding the location of your java_home you can follow this command

which java

(This will return the path of the current java binary. Over here its /usr/bin/java)

ls -alh /usr/bin/java

( This will return true path to the symbolic link. Over here its /etc/alternatives/java.

ls -alh /etc/alternatives/java

( This will return true path to this symbolic link which is actual JAVA HOME path)

Respondido 21 Feb 14, 13:02

  1. Goto Terminal and open either of the following files using an editor of your choice (vim, nano, etc):

    # nano /etc/profile
    

    (o)

    # nano /root/.bash_profile
    

    (Instead of root you can also change your normal username.)

  2. Ahora ejecute los siguientes comandos:

    # export JAVA_HOME="/opt/jdk1.6.0"
    # export PATH="/opt/jdk1.6.0/bin:$PATH"
    
  3. Logout and logon the system , now check the java version in your terminal using the following command:

    # java -version
    

    La salida debe ser similar a esto:

    # java -version
    java version “1.6.0″
    Java(TM) SE Runtime Environment (build 1.6.0-b105)
    Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
    

Respondido 23 Abr '13, 01:04

No... $JAVA_HOME must point to /home/user/jdk1.7.0_02/

To prevent errors like "/home/user" versus "/home/usr", $PATH should be "$PATH:$JAVA_HOME/bin"

And I recommend using a native package (yum, apt-get, etc).

respondido 10 mar '12, 04:03

You could put the following in your .bashrc, then it should be correct even if you change to a different java.

a=`realpath /usr/bin/java`;
export JAVA_HOME="${a%/bin/java}"

respondido 01 mar '15, 22:03

Because that's not what you set JAVA_HOME to.

http://maven.apache.org/download.html

Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=/usr/java/jdk1.5.0_02 and that $JAVA_HOME/bin is in your PATH environment variable.

respondido 10 mar '12, 04:03

JAVA_HOME typically should only include the folder that contains the bin folder.

So set it as :

export JAVA_HOME=/usr/lib/jdk1.7.0_02/

export PATH=$PATH:$JAVA_HOME/bin

After that, you can also verify using :

which java

Respondido 01 Abr '21, 07:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.