How to install Intellij IDEA on Ubuntu?

前端 未结 11 2201
無奈伤痛
無奈伤痛 2020-12-12 10:10

I\'m new to Ubuntu and Linux in general. I want to code in Java on my computer, but I\'m having problems installing IntelliJ IDEA on Ubuntu. I have downloaded and extracted

相关标签:
11条回答
  • 2020-12-12 10:50

    Note: This answer covers the installation of IntelliJ IDEA. For an extended script, that covers more JetBrains IDEs, as well as help for font rendering issues, please see this link provided by brendan.
    Furthermore, a manual Desktop Entry creation is optional, as newer versions of IntelliJ offer to create it on first startup.


    I have my intellij int /opt folder. So what I do is:

    • Download Intellij
    • Extract intellij to /opt-folder: sudo tar -xvf <intellij.tar> -C /opt/ (the -C option extracts the tar to the folder /opt/)
    • Create a Desktop Entry File called idea.desktop (see example file below) and store it anywhere you want (let's assume in your home directory)
    • Move the idea.desktop from your home directory to /usr/share/applications: sudo mv ~/idea.desktop /usr/share/applications/

    Now (in a lot) Ubuntu versions you can start the application after the GUI is restarted. If you don't know how to do that, you can restart your PC..

    idea.desktop (this is for community edition version 14.1.2, you have to change the paths in Exec= and Icon= lines if the path is different for you):

    [Desktop Entry]                                                                 
    Encoding=UTF-8
    Name=IntelliJ IDEA
    Comment=IntelliJ IDEA
    Exec=/opt/ideaIC-14.1.2/bin/idea.sh
    Icon=/opt/ideaIC-14.1.2/bin/idea.png
    Terminal=false
    StartupNotify=true
    Type=Application
    

    Edit
    I also found a shell script that does this for you, here. The given script in the link installs Oracle Java 7 for you and gives you the choice between Community and Ultimate Edition. It then automatically downloads the newest version for you, extracts it and creates a desktop entry.
    I have modified the scripts to fulfill my needs. It does not install java 8 and it does not ask you for the version you want to install (but the version is kept in a variable to easily change that). You can also update Intellij with it. But then you have to (so far) manually remove the old folder! This is what i got:

    Edit2
    Here is the new version of the script. As mentioned in the comments, breandan has updated the script to be more stable (the jetbrains website changed its behavior). Thanks for the update, breandan.

    #!/bin/sh
    
    echo "Installing IntelliJ IDEA..."
    
    # We need root to install
    [ $(id -u) != "0" ] && exec sudo "$0" "$@"
    
    # Attempt to install a JDK
    # apt-get install openjdk-8-jdk
    # add-apt-repository ppa:webupd8team/java && apt-get update && apt-get install oracle-java8-installer
    
    # Prompt for edition
    #while true; do
    #    read -p "Enter 'U' for Ultimate or 'C' for Community: " ed 
    #    case $ed in
    #        [Uu]* ) ed=U; break;;
    #        [Cc]* ) ed=C; break;;
    #    esac
    #done
    ed=C
    
    # Fetch the most recent version
    VERSION=$(wget "https://www.jetbrains.com/intellij-repository/releases" -qO- | grep -P -o -m 1 "(?<=https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/BUILD/)[^/]+(?=/)")
    
    # Prepend base URL for download
    URL="https://download.jetbrains.com/idea/ideaI$ed-$VERSION.tar.gz"
    
    echo $URL
    
    # Truncate filename
    FILE=$(basename ${URL})
    
    # Set download directory
    DEST=~/Downloads/$FILE
    
    echo "Downloading idea-I$ed-$VERSION to $DEST..."
    
    # Download binary
    wget -cO ${DEST} ${URL} --read-timeout=5 --tries=0
    
    echo "Download complete!"
    
    # Set directory name
    DIR="/opt/idea-I$ed-$VERSION"
    
    echo "Installing to $DIR"
    
    # Untar file
    if mkdir ${DIR}; then
        tar -xzf ${DEST} -C ${DIR} --strip-components=1
    fi
    
    # Grab executable folder
    BIN="$DIR/bin"
    
    # Add permissions to install directory
    chmod -R +rwx ${DIR}
    
    # Set desktop shortcut path
    DESK=/usr/share/applications/IDEA.desktop
    
    # Add desktop shortcut
    echo -e "[Desktop Entry]\nEncoding=UTF-8\nName=IntelliJ IDEA\nComment=IntelliJ IDEA\nExec=${BIN}/idea.sh\nIcon=${BIN}/idea.png\nTerminal=false\nStartupNotify=true\nType=Application" -e > ${DESK}
    
    # Create symlink entry
    ln -s ${BIN}/idea.sh /usr/local/bin/idea
    
    echo "Done."  
    

    Old Version

    #!/bin/sh                                                                                                                                   
    
    echo "Installing IntelliJ IDEA..."
    
    # We need root to install
    [ $(id -u) != "0" ] && exec sudo "$0" "$@"
    
    # define version (ultimate. change to 'C' for Community)
    ed='U'
    
    # Fetch the most recent community edition URL
    URL=$(wget "https://www.jetbrains.com/idea/download/download_thanks.jsp?edition=I${ed}&os=linux" -qO- | grep -o -m 1 "https://download.jetbrains.com/idea/.*gz")
    
    echo "URL: ${URL}"
    echo "basename(url): $(basename ${URL})"
    
    # Truncate filename
    FILE=$(basename ${URL})
    
    echo "File: ${FILE}"
    
    # Download binary
    wget -cO /tmp/${FILE} ${URL} --read-timeout=5 --tries=0
    
    # Set directory name
    DIR="${FILE%\.tar\.gz}"
    
    # Untar file
    if mkdir /opt/${DIR}; then
        tar -xvzf /tmp/${FILE} -C /opt/${DIR} --strip-components=1
    fi
    
    # Grab executable folder
    BIN="/opt/$DIR/bin"
    
    # Add permissions to install directory
    chmod 755 ${BIN}/idea.sh
    
    # Set desktop shortcut path
    DESK=/usr/share/applications/IDEA.desktop
    
    # Add desktop shortcut                     
    echo -e "[Desktop Entry]\nEncoding=UTF-8\nName=IntelliJ IDEA\nComment=IntelliJ IDEA\nExec=${BIN}/idea.sh\nIcon=${BIN}/idea.png\nTerminal=false\nStartupNotify=true\nType=Application" > ${DESK}
    
    echo "Done."    
    
    0 讨论(0)
  • 2020-12-12 10:52

    In a simple manner you can also try to just run a pre-packaged docker with intellij, I found the good job of @dlsniper : https://hub.docker.com/r/dlsniper/docker-intellij/

    you just need to have docker installed and to run :

    docker run -tdi \
           --net="host" \
           --privileged=true \
           -e DISPLAY=${DISPLAY} \
           -v /tmp/.X11-unix:/tmp/.X11-unix \
           -v ${HOME}/.IdeaIC2016.1_docker:/home/developer/.IdeaIC2016.1 \
           -v ${GOPATH}:/home/developer/go \
           dlsniper/docker-intellij
    
    0 讨论(0)
  • 2020-12-12 10:56

    Since Ubuntu 18.04 installing Intellij IDEA is easy! You just need to search "IDEA" in Software Center. Also you're able to choose a branch to install (I use EAP).

    For earlier versions:

    According to this (snap) and this (umake) articles the most comfortable ways are:

    • to use snap-packages (since versions IDEA 2017.3 & Ubuntu 14.04):

      1. install snapd system. Since Ubuntu 16.04 you already have it.

      2. install IDEA snap-package or even EAP build

    • to use ubuntu-make (for Ubuntu versions earlier than 16.04 use apt-get command instead apt):

      1. Add PPA ubuntu-desktop/ubuntu-make (if you install ubuntu-make from standard repo you'll see only a few IDE's):

        $ sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
        
      2. Install ubuntu-make:

        $ sudo apt update
        $ sudo apt install ubuntu-make
        
      3. install preffered ide (IDEA, for this question):

        $ umake ide idea
        

        or even ultimate version if you need:

        $ umake ide idea-ultimate
        
      4. I upgrade Intellij IDEA via reinstalling it:

        $ umake -r ide idea-ultimate

        $ umake ide idea-ultimate
        
    0 讨论(0)
  • 2020-12-12 10:59

    JetBrains has a new application called the Toolbox App which quickly and easily installs any JetBrains software you want, assuming you have the license. It also manages your login once to apply across all JetBrains software, a very useful feature.

    To use it, download the tar.gz file here, then extract it and run the included executable jetbrains-toolbox. Then sign in, and press install next to IntelliJ IDEA:

    If you want to move the executable to /usr/bin/ feel free, however it works fine out of the box wherever you extract it to.

    This will also make the appropriate desktop entries upon install.

    0 讨论(0)
  • 2020-12-12 10:59

    I find and follow this youtube:

    https://www.youtube.com/watch?v=PbW-doAiAvI

    Basically, download the tar.gz package, extract into /opt/, and then run the "idea.sh" under bin folder (i.e. /opt/idea-IC-163.7743.44/bin/idea.sh)

    Enjoy

    0 讨论(0)
提交回复
热议问题