Install Apache Maven in Fedora 23

Prerequisite:

  • JDK must be installed in the system.
  • Download the binary tar .gz archive file from the Apache Maven website, i.e., from the location https://maven.apache.org/download.cgi. The file will look similar to “apache-maven-3.3.9-bin.tar.gz”.

Installation:

  1. Create a new folder say “apache-maven” inside the location “/usr/local/” by running the command:

    sudo mkdir -p /usr/local/apache-maven

  2. Move the downloaded “apache-maven-3.3.9-bin.tar.gz” file to the above created folder location by running the command:

    sudo mv apache-maven-3.3.9-bin.tar.gz /usr/local/apache-maven

  3. Go to the folder location:

    cd /usr/local/apache-maven

  4. Extract the contents of the archive file:

    sudo tar -xzvf apache-maven-3.3.9-bin.tar.gz

  5. You have to set some variables like M2_HOME, M2, MAVEN_OPTS and PATH, which can be done by editing either “.profile” or “.bash_profile” file in the user’s HOME folder, or editing “/etc/profile” file. Editing the files inside the HOME folder will effect the user’s shell, while editing “/etc/profile” will make the changes available system-wide.To edit the file the command will be:

    sudo gedit
    or,
    sudo vi

    For example, to edit “/etc/profile” the command will be

    sudo gedit /etc/profile
    or,
    sudo vi /etc/profile

    The above commands will open file for editing.

  6. Add the following contents at the end of the file mentioned in Step5:

    export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
    export M2=$M2_HOME/bin
    export MAVEN_OPTS=”-Xms256m -Xmx512m”
    export PATH=$M2:$PATH

    Note: The path mentioned in the 1st line to set M2_HOME should be the location where the file gets extracted in Step2.

  7. Execute the following command:

    sudo update-alternatives –install “/usr/bin/mvn” “mvn” “/usr/local/apache-maven/apache-maven-3.3.9/bin/mvn” 1

    Note: The file location “/usr/local/apache-maven/apache-maven-3.3.9/bin/mvn” should be present inside the extracted folder in Step2.

  8. Check the maven installation by running the command:

    mvn -version

    You should get the output similar to below:

    Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T22:11:47+05:30)
    Maven home: /usr/local/apache-maven-3.3.9
    Java version: 1.8.0_66, vendor: Oracle Corporation
    Java home: /usr/java/jdk1.8.0_66/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: “linux”, version: “4.2.3-300.fc23.x86_64”, arch: “amd64”, family: “unix”

Desktop shortcut for application launcher in Fedora 23

 

In fedora you cannot right-click and create a desktop shortcut for your applications. In this post some of the ways are presented which can be used.

Method 1: If .desktop file is already present in the system

Lets say you have installed google chrome browser, and now you want to have a desktop shortcut for it.

  1. Go to location /usr/share/applications/ or ~/.local/share/applications/ using the file browser or by typing the following command:

    cd /usr/share/applications/
    or,
    ~/.local/share/applications/

  2. Check if the .desktop file is already present in the location. In the above example for google chrome browser, you may find a file like “google-chrome.desktop”.
  3. Copy the .desktop file of your application (in this case google-chrome.desktop) to following location:

    <home_folder>/Desktop

    For example if the user name is harry, copy the file to the location

    /home/harry/Desktop

  4. Give the permission to the desktop file, like chmod 755 <file_name>
  5. Done. You should be able to see the launcher of you application in the user’s desktop.

Method 2: If .desktop file is not present in the location mentioned in Method 1.

Lets say you have an launcher say “abc” in the location /home/harry/, so you have to go to the location /home/harry/ in the terminal, and run it as ./abc.

Following are the steps to create a desktop launcher (shortcut) by creating a .desktop file:

  1. Go to the location Desktop folder within home folder (i.e., <home_folder>/Desktop). For above example, go to /home/harry/Desktop.
  2. Create a file say abc.desktop using vi editor or gedit, or any file editor of your choice. The file name can be anything.
  3. Following will be the content of the abc.desktop file:

    [Desktop Entry]
    Type=Application
    Encoding=UTF-8
    Name=<Name_of_your_application>
    Comment=<Any_comment_for_your_application>
    Exec=<path_of_your_application_launcher>
    Icon=<path_of_icon_file_to_be_used_for_application>
    Terminal=false

    For the above example of “abc” application, following will be the content:

    [Desktop Entry]
    Type=Application
    Encoding=UTF-8
    Name=ABC
    Comment=My ABC Application
    Exec=/home/harry/abc
    Icon=/home/harry/icon.png
    Terminal=false

  4. Give the permission to the desktop file, like chmod 755 <file_name>
  5. Done. You should be able to see the launcher of you application in the user’s desktop.

 

Install Oracle JDK & JRE in Fedora 23

Prerequisite:

Download the rpm files for jdk and jre from the oracle website [1].

The downloaded file will have names similar to jdk-8u66-linux-x64.rpm and jre-8u66-linux-x64.rpm respectively.

Remove Pre-installed OpenJDK:

Fedora 23 comes with OpenJDK by default. To know the details of already installed Java enter the following command:

rpm -qa | grep jdk

You will get an output as follows:
java-1.8.0-openjdk-headless-1.8.0.60-14.b27.fc23.x86_64

To remove the above OpenJDK package, enter the following command:

sudo yum remove <package-name>
or,
sudo dnf remove <package-name>

For above example, the command will be as follows:

sudo dnf remove java-1.8.0-openjdk-headless-1.8.0.60-14.b27.fc23.x86_64

It will ask to remove multiple packages, type ‘y’ to proceed.

Installation of Oracle JDK & JRE:

  • Install Oracle JDK rpm package:

rpm -Uvh <path-to-jdk-rpm>

Example: rpm -Uvh jdk-8u66-linux-x64.rpm

  • Install Oracle JRE rpm package:

rpm -Uvh <path-to-jre-rpm>

Example: rpm -Uvh jre-8u66-linux-x64.rpm

  • Install java:

alternatives –install /usr/bin/java java /usr/java/latest/jre/bin/java 20000

  • Install javaws:

alternatives –install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 20000

  • Install Java Browser (Mozilla) Plugin:

For 32-bit:

alternatives –install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/jre/lib/i386/libnpjp2.so 20000

For 64-bit:

alternatives –install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/jre/lib/amd64/libnpjp2.so 20000

  • Install javac (if JDK is installed):

alternatives –install /usr/bin/javac javac /usr/java/latest/bin/javac 20000
alternatives –install /usr/bin/jar jar /usr/java/latest/bin/jar 20000

References:

  1. http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. https://ask.fedoraproject.org/en/question/8943/how-to-install-java-in-fedora-17/