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

查看:28
本文介绍了如何在 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 -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,并让您在社区版和终极版之间进行选择.然后它会自动为您下载最新版本,提取它并创建一个桌面条目.
我修改了脚本以满足我的需要.它不安装 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 网站改变了它的行为).感谢您的更新,布兰登.

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]
Encoding=UTF-8
Name=IntelliJ IDEA
Comment=IntelliJ IDEA
Exec=${BIN}/idea.sh
Icon=${BIN}/idea.png
Terminal=false
StartupNotify=true
Type=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]
Encoding=UTF-8
Name=IntelliJ IDEA
Comment=IntelliJ IDEA
Exec=${BIN}/idea.sh
Icon=${BIN}/idea.png
Terminal=false
StartupNotify=true
Type=Application" > ${DESK}

echo "Done."    

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

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