1. 安装JDK
想要跑Java程序,就必须安装JDK。JDK版本,本人用的是JDK1.7。
基本操作如下:
- 从JDK官网获取JDK的tar.gz包;
- 将tar包上传到服务器上的opt/JDK下面;
- 解压tar包;
- 更改etc/profile文件,将下列信息写在后面;(ps mac环境需要sudo su 以root权限进行操作)
cd /
cd etc
vim profile
然后进行修改 添加如下部分:
export JAVA_HOME=/opt/JDK/jdk1.7.0_79
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
改好后的profile文件信息如下:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ];