Ity*_*yav 2 java linux vim bash tomcat
我已经从一家顶级托管公司购买了 VPS。我是 Linux 新手。由于我无法购买 CPanel 许可证,因此我需要手动安装 JDK、Tomcat 和 MariaDB。所有这一切都通过使用 PUTTY 的 SSH 进行。
我遵循了一些教程:
在 CentOS 6 中设置 JAVA_HOME 和 CLASSPATH
如何在 CentOS 7.3 上安装 Apache Tomcat 8.5
但由于我是 Linux 新手,只能安装 JDK8。
现在我需要在 bash 文件中设置 JAVA_HOME 以保持永久状态,然后才能继续安装 tomcat。
从 PUTTY 中,我使用密码以 root 用户身份登录:
我检查了Java的位置"which java" : /usr/bin/java
为了获得确切的jdk名称,我使用了命令 "sudo update-alternatives --config java"> java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64/jre/bin /java)
我通过命令创建了一个新文件,"vim /etc/profile.d/java.sh"该文件给出了以下错误:
E325: ATTENTION
Found a swap file by the name "/etc/profile.d/.java.sh.swp"
owned by: root dated: Thu Oct 19 14:21:28 2017
file name: /etc/profile.d/java.sh
modified: YES
user name: root host name: rtp
process ID: 31766
While opening file "/etc/profile.d/java.sh"
(1) Another program may be editing the same file. If this is the case,
be careful not to end up with two different instances of the same
file when making changes. Quit, or continue with caution.
(2) An edit session for this file crashed.
If this is the case, use ":recover" or "vim -r /etc/profile.d/java.sh"
to recover the changes (see ":help recovery").
If you did this already, delete the swap file "/etc/profile.d/.java.sh.swp"
to avoid this message.
Swap file "/etc/profile.d/.java.sh.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
Run Code Online (Sandbox Code Playgroud)
我按下d删除现有的。
export JAVA_HOME=/usr/bin/java/java-1.8.0-openjdk.x86_64
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
Run Code Online (Sandbox Code Playgroud)
然后我按 ENTER 键
该文件处于插入模式,因此我按Esc :w java.sh保存并退出。
然后我关闭了 PUTTY 会话并再次开始检查 JAVA_HOME 是否已设置:"echo $JAVA_HOME"
没有结果!
我不明白又该做什么。这两天我一直在重复这件事。请问有什么帮助吗?
小智 5
在将其添加到 java.sh 之前,在 shell 提示符下运行以下命令:
export JAVA_HOME=/usr/bin/java/java-1.8.0-openjdk.x86_64
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
Run Code Online (Sandbox Code Playgroud)
然后运行echo $JAVA_HOME
| 归档时间: |
|
| 查看次数: |
31507 次 |
| 最近记录: |