domingo, 7 de febrero de 2016

Make shure that you don't have a JDK previews version installed.


The first step is search a previews version of JDK on our system.
For check if we have JDK installed, you need open a terminal and enter this command:

$ sudo apt-get purge icedtea-* openjdk-* 

If you find a version installed, you have to uninstall using the next command:

$ sudo apt-get remove --purge openjdk-*

We ensure that no trace exist more:

$ sudo dpkg --list | grep -i jdk 
$ java -version

"If you have still a JDK version installed, you will see information about version installed"

Make sure that you have ready for start to install, make a search for last time for JDK versions installed on the System and uninstall it.

$ sudo apt-get purge openjdk-*

Beginning with the installation.

Make a new folder called java on /usr/local.
You can using this command:

$ sudo mkdir -p /usr/local/java

 Download the last JDK version from Official Oracle site.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

When you have the last JDK version downloaded, get the file path for example I have this path in my PC, because I copied the file downloaded on this folder.
"You can copy the file from Downloads Folder...
The objetive is copy the file to new Folder called java"


We position ourselves in the folder containing the downloaded file.
$ cd /home/usanchezm/SoftResources/

 Copy the file to the new folder called java
$ sudo cp -r jdk-8u72-linux-x64.tar.gz /usr/local/java 

Is very important you being root user

$ sudo cp -r jdk-8u72-linux-x64.tar.gz /usr/local/java 

Note: The name file that I downloaded is  jdk-8u72-linux-x64.tar.gz,
perhaps now there is a new version.
Make shure of replace the new name  in the commands.

Now we position ourselves in the folder called java That we did.
$ cd /usr/local/java 

 Give permission of modification of arguments.
$ sudo chmod a+x jdk-8u72-linux-x64.tar.gz


 Extract content of package.
$ sudo tar xvzf jdk-8u72-linux-x64.tar.gz

 Now you can use NetBeans without problems, but still missing do enviroment variables.

Open a text editor from terminal for editing of profile file.

Ubuntu
$  sudo gedit /etc/profile
Xubuntu
$  sudo mousepad /etc/profile
Lubuntu
$  sudo leafpad /etc/profile 

When you have the file open, copy this lines to the end of file:


JAVA_HOME=/usr/local/java/jdk1.8.0_72
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH



The next step is save and close.

 Load the configuration:

$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_72/bin/java" 1
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_72/bin/javac" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_72/bin/javaws" 1

Set default settings for use jdk installed.
$ sudo update-alternatives --set java /usr/local/java/jdk1.8.0_72/bin/java 

Set the java compiler.

$ sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_72/bin/javac

Set the Java Web Start
$ sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_72/bin/javaws 

Load the profile file:

$ . /etc/profile 

To check version:

$    java -version
$    javac -version 

If you can see Information about JDK installed version. Congratulation...
You have JDK correct installed.
Happy code sentences.