一般来说,我是Ubuntu和Linux的新手。我想在计算机上用Java编写代码,但是在Ubuntu上安装IntelliJ IDEA时遇到问题。我已经下载并解压缩了文件,并且由于某种原因将该文件夹重命名为idea。我尝试将文件夹移至/usr/share/applications或其他位置,但没有权限。我sudo -i在终端中使用以获得许可,但没有设法退出根文件夹。谁能一步一步地为我提供帮助,以移动文件夹,在搜索栏中创建快捷方式或所谓的快捷方式并正确安装它?
/usr/share/applications
sudo -i
注意: 此答案涵盖了IntelliJ IDEA的安装。有关涵盖更多JetBrains IDE的扩展脚本以及字体渲染问题的帮助,请参见brendan提供的此链接。 此外,手动创建Desktop Entry是可选的,因为IntelliJ的较新版本提供了在首次启动时进行创建的功能。
我有intellij int / opt文件夹。所以我要做的是:
sudo tar -xvf <intellij.tar> -C /opt/
sudo mv ~/idea.desktop /usr/share/applications/
现在(很多)Ubuntu版本可以在GUI重新启动后启动应用程序。如果您不知道该怎么做,则可以重新启动PC。
idea.desktop(这是针对社区版本14.1.2的,如果路径与您不同,则必须在Exec =和Icon =行中更改路径):
[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。但是,您必须(到目前为止)手动删除旧文件夹!这就是我得到的:
Edit2 这是脚本的新版本。如评论中所述,breandan已将脚本更新为更稳定(jetbrains网站已更改其行为)。谢谢你的更新,布兰丹。
#!/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."