如何在Ubuntu上安装Intellij IDEA? [英] How to install Intellij IDEA on Ubuntu?

查看:136
本文介绍了如何在Ubuntu上安装Intellij IDEA?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Ubuntu和Linux的新手。我想在我的计算机上用Java编写代码,但是我在安装 IntelliJ IDEA <时遇到问题/ a>在Ubuntu上。我已下载并解压缩文件,并出于某种原因将文件夹重命名为idea。我尝试将文件夹移动到 / usr / share / applications 或其他东西,但我没有权限。我在终端中使用 sudo -i 来获得权限,但没有设法退出根文件夹。任何人都可以帮我一步一步地移动文件夹,在搜索栏中创建快捷方式或者调用它的任何东西并正确安装吗?

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 the file and for some reason renamed the folder to idea. I tried moving the folder to /usr/share/applications or something but I didn't have permission. I used sudo -i in terminal to gain permission but didn't manage to get out of root folder. Can anyone help me with a step by step way to move the folder, create a shortcut in the search bar or whatever it's called and install it properly?

推荐答案

注意:这个答案涵盖了IntelliJ IDEA的安装。对于包含更多JetBrains IDE的扩展脚本以及字体渲染问题的帮助,请参阅此链接由brendan提供。

此外,手动桌面条目创建是可选的,因为较新版本的IntelliJ提供在首次启动时创建它。

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.

我有我的intellij int / opt文件夹。所以我所做的是:

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


  • 下载Intellij

  • 将intellij提取到/ opt-folder: sudo tar -xvf< intellij.tar> -C / opt / (-C选项将tar提取到文件夹/ opt /)

  • 创建名为idea.desktop的桌面条目文件(参见示例下面的文件)并将其存储在您想要的任何地方(让我们假设在您的主目录中)

  • 将idea.desktop从您的主目录移动到/ usr / share / applications: sudo mv~ / idea.desktop / usr / share / applications /

  • 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/

现在(很多) )Ubuntu版本,您可以在重新启动GUI后启动应用程序。如果你不知道怎么做,你可以重新启动你的电脑..

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(这是社区版14.1.2,你必须如果路径不同,则更改Exec =和Icon =行中的路径):

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






编辑

我还找到了一个shell脚本,为您完成此操作, 此处。链接中的给定脚本为您安装Oracle Java 7,并为您提供Community和Ultimate Edition之间的选择。然后它会自动为您下载最新版本,将其解压缩并创建桌面条目。

我已修改脚本以满足我的需求。它不会安装java 8,也不会要求您提供要安装的版本(但版本保存在变量中以便轻松更改)。您也可以使用它更新Intellij。但是你必须(到目前为止)手动删除旧文件夹!这就是我得到的:


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

这是脚本的新版本。正如评论中所提到的,breandan已将脚本更新为更稳定(jetbrains网站改变了其行为)。感谢更新,breandan。

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."  






旧版本

#!/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."    

这篇关于如何在Ubuntu上安装Intellij IDEA?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆