Java configuration on linux

Asked

Viewed 103 times

2

I’m setting up JAVA and ANT on Linux Server, following a few steps I found on the internet, because I’ve never done this on Linux. I set them up by the terminal because I’m accessing the machine through the SSH. I’m setting it up this way:

export ANT_HOME=/root/Desktop/apache-ant/apache-ant-1.7.1

export JAVA_HOME=/root/bea/jdk160_05

export PATH=${PATH}:${ANT_HOME}/bin

export PATH=${PATH}:${JAVA_HOME}/bin

export CLASSPATH=.:$JAVA_HOME/bin

but when I do

java -version

appears

java version "1.7.0_51"
OpenJDK Runtime Environment (fedora-2.4.4.1.fc20-x86_64 u51-b02)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

The java I am configuring is 1.6.0_05.

and when I make the following command

javac -version

the version that appears is

javac 1.6.0_05

I wonder why when I give a java -version is not the version 1.6.0_05 that appears.

PS: Don’t worry about the java version, I’m doing some tests and I was trying to configure the previous java anyway

  • 1

    On debian systems has a bid of java alterantives... Give a search on this. It is for you to switch between versions of Java and choose a default, if I am not mistaken.

  • If you want to force the path choose the desired order: export PATH=$ANT_HOME/bin:$PATH

  • 1

    @Jjoao It worked what you said, interesting, I thought doing the export PATH=${PATH}:${JAVA_HOME}/bin I put it in front.

  • @Igorventurelli thanks for the tip, I took a brief look seems to be interesting

  • To know which java is being called: which java

1 answer

0


  1. Remove the Openjdk file.
  2. download the JDK on the Oracle website and unzip the package in your preferred folder, in my case I use /usr/local/java.
  3. use update-alternatives to configure the executable, as in the following example:
    sudo update-alternatives --install "/usr/bin/java" "java" "caminho_do_jdk/bin/java" 1
  4. repeat operation for javac and javaws.
  5. Create and export your JAVA_HOME within your terminal configuration file (bashrc, zshrc etc).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.